Initiate the payment flow
Start a new payment flow using a payment session from our SDK. This endpoint creates a payment and returns a unique payment ID that you can use to track its status.
The payment flow typically involves:
- Your customer selecting a payment method in the SDK
- You initiating the payment with the session ID from step 1
- The customer completing the payment via their selected payment method
- Our system notifying you of the final payment status via webhook, or you polling the status of the payment
The payment ID returned by this endpoint can be used to track the payment status and details.
external_id
string
Optional. Your unique reference for this payment, such as an order or invoice number. You can use this ID later to look up the payment instead of our payment ID. Must be unique across all your payments.
amount
string
Required. The payment amount in the smallest currency unit (e.g. satang). For example, use 10000 for 100 THB. Must be a positive integer.
currency
string
Required. The three-letter ISO currency code (e.g. THB). Must match the currency configured for your merchant account.
payment_session_id
string
Required. The session ID received from our SDK after the customer selects their payment method. This connects the customer's payment method choice to this payment.
card_id
string
Optional. The ID of a previously saved card (starting with crd_) or your own
external card identifier. When provided for a card payment session that
doesn't have a token attached, we'll use this saved card's token for the
payment.
Required when the payment session's payment method is CARD and no token was provided during select-payment-method.
capture
boolean
Required. Controls when funds are captured. Set to true to capture funds immediately upon payment authorization, or false to only authorize funds for later capture. Useful for businesses that ship physical goods or need to verify orders before charging.
return_url
string
Required. The URL where we'll redirect your customer after they complete the payment flow. Should be a page that can handle both successful and failed payments.
customer_id
string
Optional. Either a Customer ID (starting with ctc_) or your own external
customer identifier. We'll link this payment to an existing customer
if found, or create a new customer if not. This helps track payment
history per customer.
If you provide your own external ID and a customer with that ID doesn't exist, we'll create a new customer using that ID as their external identifier.
customer_email
string
Optional. The customer's email address. If provided, we'll either:
- Link this payment to an existing customer with this email
- Create a new customer with this email if no match is found
- Update the email for the customer specified in customer_id (if provided)
customer_mobile
string
Optional. The customer's mobile number. If provided, we'll either:
- Link this payment to an existing customer with this mobile
- Create a new customer with this mobile if no match is found
- Update the mobile for the customer specified in customer_id (if provided)
customer_name
string
Optional. The customer's name. If provided, we'll either:
- Update the name for an existing customer if found
- Set the name when creating a new customer
- Update the name for the customer specified in customer_id (if provided)
save_card
string
Optional. Option to save the card used in this payment session to the contact. Only applicable when the payment session uses a card token. The card will be saved if the token is multi-use.
ADD: Add the card to the contact without setting it as defaultDEFAULT: Add the card to the contact and set it as the default card
If any error occurs while saving the card, it will be silently ignored and will not block the payment flow.
NOT_FOUND
The payment session ID provided doesn't match any active session in our system, or the card_id doesn't match any card belonging to the customer. This usually means the session has expired or was already used, or the card has been deleted. The customer should select their payment method again in the SDK to generate a new session.
CONFLICT
The payment session amount and currency do not match the amount and currency provided in the request. The payment session was created with specific values that must match when initiating the payment flow. Ensure the amount and currency in your request match the values used when creating the payment session.
NOT_SUPPORTED
The payment method selected does not support the requested operation. This occurs when capture is set to false but the payment method's integrations do not support authorization without capture. Choose a different payment method or set capture to true.
UNHANDLED_ERROR
This error occurs when the server encounters an unexpected internal error that it cannot handle gracefully. This typically happens due to bugs, infrastructure issues, or edge cases that weren't anticipated during development.
INVALID_ARGUMENTS
This error occurs when the request contains invalid or missing parameters. Common cases include missing required fields, or values that don't match the expected format or type.
BAD_VERSION
This error occurs when making requests to an API version that does not exist. This commonly happens when using an outdated SDK or when the API version specified in the request URL is incorrect.
curl "https://api.reservepay.com/merchants/initiate-payment-flow" \
-X POST
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $(RESERVEPAY_API_KEY)" \
-d '{
"external_id": "489347-947/1",
"amount": 100000,
"currency": "THB",
"payment_session_id": "pse_01jz1r162nn728gn7etv77p9v6",
"capture": true,
"return_url": "https://store.mydomain.com/orders/489347-947",
"customer_id": "3947",
"customer_email": "joe.doe@example.com"
}'
