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
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.Create payment
Send the
tok_* token to your backend, then call POST /v1/payments with the token parameter using your secret access token.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.
| Field | Description |
|---|---|
id | Token ID (tok_ prefix). Valid for 30 minutes, single use. |
card.bin | First 6 digits of the card |
card.last4 | Last 4 digits |
card.brand | Card brand (visa, mastercard, amex, etc.) |
card.exp_month | Expiration month |
card.exp_year | Expiration year |
expires_at | Token expiration timestamp (ISO 8601) |
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:| Status | HTTP Code | Action |
|---|---|---|
completed | 201 | Payment succeeded. Show success page. |
authorized | 201 | Authorization succeeded (when capture_method: "manual"). Capture later. |
requires_action | 202 | 3D Secure required. Redirect customer to redirect_url. |
failed | 400 | Payment failed. Show error to customer. |
Full Example
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 Access.
For details, see Authentication.
Test Cards
| Card Number | Description |
|---|---|
| 4242424242424242 | Successful payment |
| 4000002500003155 | Requires 3D Secure |
| 4000000000000002 | Declined |
| 4000000000009995 | Insufficient funds |
For complete API parameters and response details, see the Create Payment API reference and Create Token API reference.