Use XPay customer records to keep a consistent customer identity across payments, saved payment methods, and subscriptions. Store the XPay customer ID against the corresponding customer or account in the merchant system.
Before you begin
Configure XPay API authentication. Create and manage customers from the merchant backend so API credentials and customer data are not exposed in frontend code.
Customer endpoints
The customer endpoints use the following base path:
{{base_url}}/public/v1/customerProvide at least one of email or phone when finding a customer without its XPay ID. List responses are paginated.
Create a customer
Send an authenticated request containing the customer details the merchant needs to reuse:
{
"email": "ayesha@example.com",
"phone": "{{customer_phone}}",
"first_name": "Ayesha",
"last_name": "Khan",
"shipping_address": {
"address1": "12 Example Road",
"city": "Lahore",
"country": "Pakistan",
"province": "Punjab",
"zip": "54000"
},
"metadata": {
"merchant_customer_reference": "customer-1001"
}
}Store the returned customer ID. Use partial fields when updating a customer with PATCH.
Use a customer when creating a payment token
To associate a token-creation payment with an existing customer, include the XPay customer ID when creating the PaymentIntent. XPay uses the stored customer details and associates a successfully created token with that customer. Follow Collect a payment token with XPay Element for the required PaymentIntent fields and complete flow.
Generate a customer payment link for token creation
Send an authenticated request to:
POST {{base_url}}/public/v1/customer/payment/link/{{customer_id}}This operation generates a one-time payment link for token creation for the selected customer. The current public contract uses a fixed charge of 5, which can be refunded after the token is created. This customer token-creation link is different from a general payment link created for an order amount.