Payment Sessions allow you to securely collect payment followed by storing the payment method for future transactions simultaneously. The stored payment channel can be used for subsequent transaction initiated by either your system or directly by the end-user within your application.
Example usage:
Subscription Service (SaaS/Media): First-time subscription activation: A user signs up for a monthly plan that requires immediate first-month payment.
eCommerce: Purchasing products for the first time and saving the payment method for easier subsequent purchase
There are two main options for enabling the Pay and Save feature on Payment Sessions:
Forced: The checkout page will always save the payment details after payment and will only display payment methods that support save method.
Optional: Allows the end user to explicitly opt-in to save the payment details for future use. When the checkbox is opted-in, the flow becomes Pay & Save; otherwise, it defaults to a standard One Time Payment.
How to integrate

During checkout or whenever your customer is ready to make a payment, your system should Create a Payment Session with Xendit using the example payload provided below.
For Cards, it's recommended to specify
channel_properties.cards.card_on_file_typeduring Payment Session creation. This field indicates the intended use of the payment token for subsequent transactions—whether RECURRING, MERCHANT_UNSCHEDULED, or CUSTOMER_UNSCHEDULED. Properly setting this value can significantly improve transaction success rates.There are two options on
allow_save_payment_method:Forced: Always save the payment details
Request - POST /sessions{ "reference_id": "{{$YOUR_REFERENCE_ID}}", "session_type": "PAY", "mode": "PAYMENT_LINK", "amount": 150000, "currency": "IDR", "country": "ID", "customer": { "reference_id": "{{$randomUUID}}", "type": "INDIVIDUAL", "email": "customer@yourdomain.com", "mobile_number": "+628123456789", "individual_detail": { "given_names": "John", "surname": "Doe" } }, "channel_properties": { "cards":{ "card_on_file_type": "CUSTOMER_UNSCHEDULED" } }, "success_return_url": "https://yourcompany.com/order/complete", "cancel_return_url": "https://yourcompany.com/order/cancel", "allow_save_payment_method": "FORCED" }{ "payment_session_id": "ps-690a1efdb6b78faccd6295b3", "created": "2025-11-04T15:42:53.811Z", "updated": "2025-11-04T15:42:53.811Z", "status": "ACTIVE", "reference_id": "5daba2e1-b488-4096-b400-2f234d1d45eb+3", "currency": "IDR", "amount": 150000, "country": "ID", "expires_at": "2025-11-04T16:12:53.509Z", "session_type": "PAY", "mode": "PAYMENT_LINK", "locale": "en", "business_id": "610d01ea382dd240ac8f913d", "customer_id": "cust-b8af2920-b9e2-4ebd-bdea-ef52af1fe8bf", "capture_method": "AUTOMATIC", "channel_properties": { "cards": { "card_on_file_type": "CUSTOMER_UNSCHEDULED" } }, "success_return_url": "https://yourcompany.com/order/complete", "cancel_return_url": "https://yourcompany.com/order/cancel", "payment_link_url": "https://dev.xen.to/k75cVqXj", "allow_save_payment_method": "FORCED" }.png?sv=2022-11-02&spr=https&st=2025-11-13T22%3A58%3A26Z&se=2025-11-13T23%3A11%3A26Z&sr=c&sp=r&sig=nWYmm7jCjL0rQNPgCO4Zt5ZTDtf4dgy5Obz654KoMWI%3D)
The checkout page will always save the payment details after payment and always shows the available channels that support save method.
Optional: Allows the end user to opt-in to save the payment details
Request - POST /sessions{ "reference_id": "{{$YOUR_REFERENCE_ID}}", "session_type": "PAY", "mode": "PAYMENT_LINK", "amount": 150000, "currency": "IDR", "country": "ID", "customer": { "reference_id": "{{$randomUUID}}", "type": "INDIVIDUAL", "email": "customer@yourdomain.com", "mobile_number": "+628123456789", "individual_detail": { "given_names": "John", "surname": "Doe" } }, "channel_properties": { "cards":{ "card_on_file_type": "CUSTOMER_UNSCHEDULED" } }, "success_return_url": "https://yourcompany.com/order/complete", "cancel_return_url": "https://yourcompany.com/order/cancel", "allow_save_payment_method": "OPTIONAL" }{ "payment_session_id": "ps-690a1efdb6b78faccd6295b3", "created": "2025-11-04T15:42:53.811Z", "updated": "2025-11-04T15:42:53.811Z", "status": "ACTIVE", "reference_id": "5daba2e1-b488-4096-b400-2f234d1d45eb+3", "currency": "IDR", "amount": 150000, "country": "ID", "expires_at": "2025-11-04T16:12:53.509Z", "session_type": "PAY", "mode": "PAYMENT_LINK", "locale": "en", "business_id": "610d01ea382dd240ac8f913d", "customer_id": "cust-b8af2920-b9e2-4ebd-bdea-ef52af1fe8bf", "capture_method": "AUTOMATIC", "channel_properties": { "cards": { "card_on_file_type": "CUSTOMER_UNSCHEDULED" } }, "success_return_url": "https://yourcompany.com/order/complete", "cancel_return_url": "https://yourcompany.com/order/cancel", "payment_link_url": "https://dev.xen.to/k75cVqXj", "allow_save_payment_method": "OPTIONAL" }.png?sv=2022-11-02&spr=https&st=2025-11-13T22%3A58%3A26Z&se=2025-11-13T23%3A11%3A26Z&sr=c&sp=r&sig=nWYmm7jCjL0rQNPgCO4Zt5ZTDtf4dgy5Obz654KoMWI%3D)
The interface will show all available payment channels, and only those channels that support the Save functionality will present a visible checkbox for the end-user to opt-in to the Pay & Save flow.
Once the Payment Session is created, redirect your end user to the Xendit-hosted checkout page using the
payment_link_urlfrom the response.Your customer will complete the payment on the Xendit-hosted page using their preferred payment channel (e.g., cards, eWallets, etc.).
For the optional value, it will follow the pay and save if the customer toggles the checkbox, otherwise, it will be treated as one-time payment
Your end user will complete their payment process and linking process on Xendit-hosted page
Upon successful payment, Xendit will send a
payment_session.completed,payment.captureandpayment_token.activatedorpayment.failedwebhook to your system. This webhook containspayment_token_id, which you should securely store for future use.You should use these webhooks to update the order status in your system and use the
payment_token_idfor:Future one-off payments: Refer to the Pay with Tokens guide
Subscription transactions: Refer to the guides on Fixed Amount Subscriptions or Usage-Based Subscriptions.