Send authenticated customer information
To authenticate a customer profile, your backend server must make two independent API calls, which we recommend running in parallel for better performance:
-
createCart
: Generates the Zonos cart. For detailed guidance, refer to the Set up Zonos Checkout section within the custom integration documentation. -
checkoutCustomerProfileAuthenticate
: Submits and validates the customer's information.
Mutation
mutation checkoutCustomerProfileAuthenticate(
$input: CheckoutCustomerProfileAuthenticateInput!
) {
checkoutCustomerProfileAuthenticate(input: $input) {
email
customerId
organizationId
name
phone
locations {
administrativeArea
countryCode
locality
line1
line2
postalCode
}
oneTimePassword
}
}
Variable
{
"input": {
"email": "test@zonos.com",
"locations": [
{
"administrativeArea": "BC",
"countryCode": "CA",
"line1": "411-1033 Davie Street",
"line2": "123 testAddress2",
"locality": "Vancouver",
"name": "TestCanada TestCanada",
"postalCode": "V6E1M7"
},
{
"administrativeArea": "UT",
"countryCode": "US",
"line1": "411-1033 Davie Street",
"line2": "123 testAddress2",
"locality": "Saint George",
"name": "TestUS TestLastName",
"postalCode": "84770"
}
],
"customerId": "1234567",
"name": "testFirstName1 testLastName",
"phone": "7022920000"
}
}
When validating the customer session, ensure that the customerId
you pass in the request matches the correct profile to display accurate customer information at checkout. Keep in mind that when creating a cart, you should not include customerId
in the metadata, as it will be overwritten.
After the customer is authenticated and the order is placed, the customerId will be available in order.references
when retrieving order details via the order query, allowing you to associate the order with the correct customer.
Create cart with customer profile
After you call both mutations, you will get the following back:
-
cartId
from thecreateCart
mutation to generate the cart. -
A
oneTimePassword
from thecheckoutCustomerProfileAuthenticate
mutation for the customer authentication.
You can pass both of these values in the createCartId
callback in the Zonos.init
function to load the provided customer profile information in Checkout.
Zonos.init
Zonos.init({
...
checkoutSettings: {
...
createCartId: async () => {
const result = await fetch(
'https://api.merchant.com/api/get-cart-info',
{
body: JSON.stringify(payload),
method: 'POST',
},
);
const json =
await result.json();
return {
cartId: json.cartId,
customerAuthenticationToken:
json.customerProfileAuthenticate
?.checkoutCustomerProfileAuthenticate.oneTimePassword ||
'',
};
}
},
}
Manage customer profiles
The first time you submit customer information, Zonos will store the provided customer information. Payment methods will be stored securely in Stripe. Each time new address or payment method details are passed in, they will be added to the customer’s profile.
Currently, customer profiles can only be updated with additional information—existing details cannot be edited or removed.
Customer profiles
Pre-load recurring shopper information into Zonos Checkout.Customer profiles streamline your checkout experience by allowing customers with an account to pre-load their address and payment details.
This feature is currently only available for custom API integrations. This feature is not yet available for merchants using Checkout plugins.