Payment Sessions allow you to securely store your users' payment channels for future transactions. This feature ensures regulatory compliance and simplifies the integration process. Once a payment channel is stored, it can be used for subsequent transactions initiated by either your system or directly by the end-user within your application.
How to integrate
During the end user's registration or via a menu option where users can store their payment channels, your system should Create a Payment Session with Xendit using the example payload provided below.
Request - POST /sessions
{ "reference_id": "{{$randomUUID}}", "session_type": "SAVE", "mode": "PAYMENT_LINK", "amount": 0, "currency": "IDR", "country": "ID", "customer": { "reference_id": "{{$randomUUID}}", "type": "INDIVIDUAL", "email": "test@yourdomain.com", "mobile_number": "+6212345678", "individual_detail": { "given_names": "Lorem", "surname": "Ipsum" } }, "channel_properties": { "cards":{ "card_on_file_type":"RECURRING" } }, "success_return_url":"https://yourcompany.com/example_item=my_example_item", "cancel_return_url":"https://yourcompany.com/example_item=my_example_item" }
Response - POST /sessions
{ "payment_session_id": "ps-67527107dda8b2513acdaef0", "created": "2024-12-06T03:35:36.032Z", "updated": "2024-12-06T03:35:36.032Z", "status": "ACTIVE", "reference_id": "b767f88f-b5bc-4836-9c47-c14261909dec", "currency": "IDR", "amount": 0, "country": "ID", "customer_id": "cust-fe8743c3-f554-4d25-a0e9-9980226c4b1b", "expires_at": "2024-12-06T04:05:35.049Z", "session_type": "SAVE", "mode": "PAYMENT_LINK", "locale": "en", "business_id": "62440e322008e87fb29c1fd0", "channel_properties": { "cards":{ "card_on_file_type":"RECURRING" } }, "success_return_url": "https://yourcompany.com/example_item=my_example_item", "cancel_return_url": "https://yourcompany.com/example_item=my_example_item", "payment_link_url": "https://dev.xen.to/qZx5RD_7" }
For Cards, it's recommended to specify
channel_properties.cards.card_on_file_type
during 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.
Once the Payment Session is created, redirect your end user to the Xendit-hosted page using the
payment_link_url
from the response.Your end user will complete their linking process on Xendit-hosted page
Upon successful linking, Xendit will send a
payment_session.completed
webhook to your system. This webhook contains thepayment_token_id
, which you should securely store for future use.You can use the
payment_token_id
for:Future one-off payments: Refer to the Payments with Token guide.
Subscription transactions: Refer to the guides on Fixed Amount Subscriptions or Usage-Based Subscriptions.