Call confirmPayment() from the customer-facing application after XPay Element is ready and the merchant backend has created the PaymentIntent.
Before you begin
The frontend needs:
- The selected payment-method type.
- The PaymentIntent
pi_client_secret. - The customer information required by the SDK.
- The PaymentIntent
encryptionKey.
Obtain these values through the merchant backend. Do not expose the merchant API key or API signature secret.
Confirm with Web SDK v5
Web SDK v5 accepts one options object:
JavaScript
try {
const result = await xpay.confirmPayment({
paymentMethodType: "card",
clientSecret: paymentIntent.pi_client_secret,
customer: {
name: "Ayesha Khan"
},
encryptionKey: paymentIntent.encryptionKey
});
updateCheckout(result);
} catch (error) {
showPaymentError(error.message);
}Use the SDK result to guide the immediate customer experience. The reusable payment token is not returned through this method; XPay delivers it through the verified webhook for a token-collection flow.
Handle the later result
Payment processing can continue after the SDK call. On the merchant backend:
- Verify XPay webhook signatures.
- Match the PaymentIntent ID to the merchant order.
- Store the current PaymentIntent status.
- Fulfill the order only after the accepted payment result satisfies the merchant's business rules.
See PaymentIntent lifecycle and statuses for the supported states documented by XPay.
Next steps
- Integrate XPay webhooks.
- Capture a payment later when
capture_methodismanual. - Upgrade to Web SDK v5 if the integration still uses positional arguments.