Overview
Server-to-Server (S2S) payments let you collect card details on your own payment form instead of using the hosted checkout page. Card data is securely tokenized in the browser using our JavaScript SDK, and the token is sent to your server to create a payment.S2S integration requires PCI SAQ A-EP compliance. If you are unsure about your PCI compliance level, use hosted checkout instead.
How It Works
1
Tokenize card in browser
Call
POST /v1/tokens with your publishable key (pk_live_* / pk_test_*) to tokenize card details. You can use the JavaScript SDK or call the API directly. The raw card number never reaches your server.2
Create payment
Send the
tok_* token to your backend, then call POST /v1/payments with the token parameter using your secret access token.3
Handle 3D Secure (if required)
If the response status is
requires_action, redirect the customer to redirect_url to complete 3D Secure authentication.Integration
1. Tokenize card details
Collect card details on your payment page and send them toPOST /v1/tokens using your publishable key. You can use the JavaScript SDK or call the API directly.
The JavaScript SDK returns the token ID as
token instead of id for convenience. When calling the API directly, the field name is id.2. Create payment with token
On your server, callPOST /v1/payments with the token.
3. Handle the response
The response status determines the next step:
Handling 3D Secure:
Save Card for Recurring Payments
You can save the customer’s card during an S2S token payment by addingsave_card: true and customer_id to the payment request. After the payment completes (including 3D Secure if required), the card is saved and a payment_method_id is returned in the webhook.
Request
boolean
Set to
true to save the card after payment completion.string
Required when
save_card is true. A unique ID to identify the customer.Webhook
On payment completion, the webhook includes the savedpayment_method_id:
Subsequent Recurring Payments
Use the savedpayment_method_id to charge the customer without requiring card input or tokenization:
Full Example
Client-side (Browser)
Server-side
Publishable Key
The publishable key (pk_test_* / pk_live_*) is used to authenticate tokenization requests from the browser. It can only be used to create tokens and cannot access payments, customers, or any other API resources.
You can obtain your publishable key from the merchant dashboard under Merchant Settings > API Settings.
For details, see Authentication.
Test Cards
For complete API parameters and response details, see the Create Payment API reference and Create Token API reference.