API Integration
Create and retrieve Checkout sessions from your backend.
Your backend creates a Checkout session for each order and retrieves it to verify the payment.
For Node.js, the @tapayadot/checkout SDK provides typed create() and get() methods for these endpoints. It reads TAPAYA_SECRET_KEY by default. The HTTP examples on this page pass TAPAYA_CHECKOUT_API_KEY explicitly.
Authentication
Use the Secret key from the API Keys page in the Tapaya Platform for your environment.
Store it in TAPAYA_CHECKOUT_API_KEY on your server and send it with both Checkout calls:
Authorization: Bearer <secret-key>This is the same organization credential called a Server Secret Token in the Platform API docs.
Checkout requires the Bearer prefix. Other Platform API endpoints take the token directly, without that prefix.
Keep the key on your server; see Checkout Security.
Which merchant receives the payment
Checkout uses the key's organization to find a merchant with the same registration number as the organization. Exactly one merchant must match, and that merchant must be active. If no merchant matches, multiple merchants match, or the matching merchant is inactive, authentication fails. In sandbox, an explicitly selected Checkout merchant can override registration-number matching, but must belong to the organization and be active.
Support for multiple merchants per organization is planned for a future release. The single-merchant matching requirement applies today.
Checkout session requests do not accept a merchantId to select another merchant.
For reseller integrations, the backend also supports separately issued merchant-specific keys that identify one merchant directly.
The Secret key from API Keys is sufficient for Checkout for your own organization when the matching requirements above are met.
Merchant onboarding and organization management use the Platform API.
Environments
- Development:
https://api.sandbox.tapaya.com, with the development gateway's test cards. - Production: the API base URL supplied for your deployment.
Checkout Sessions
Create a Checkout Session
Create a session when the customer clicks Checkout in your shop, then redirect them to the returned url.
Calculate the final total on your server and persist the order with a unique idempotency key first.
Endpoint: POST /merchant/checkout-sessions
curl -X 'POST' "$TAPAYA_CHECKOUT_API_URL/merchant/checkout-sessions" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TAPAYA_CHECKOUT_API_KEY" \
-H 'Idempotency-Key: order-1001-checkout-1' \
-d '{
"merchantOrderId": "order-1001",
"amount": 12100,
"currency": "EUR",
"tax": 2100,
"shipping": 605,
"taxRate": 21,
"successUrl": "https://shop.example/checkout/return",
"cancelUrl": "https://shop.example/checkout/cancel"
}'Headers:
| Header | Required | Description |
|---|---|---|
Authorization | ✓ | Bearer <secret-key>. |
Idempotency-Key | ✓ | Nonblank, at most 255 characters. See Idempotency and errors. |
Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
amount | integer | ✓ | Final charge total in currency minor units, including tax and shipping. 1 to 2,147,483,647. |
currency | string | ✓ | Three-letter ISO 4217 code supported by the backend, in uppercase, such as EUR. |
merchantOrderId | string | Your order reference. Generated when omitted. Does not replace an idempotency key. | |
locale | string | Defaults to en. | |
successUrl | string | URL that overrides the merchant's default success URL for this session. | |
cancelUrl | string | URL that overrides the merchant's default cancel URL for this session. | |
tax | integer | VAT already included in amount, between zero and amount. Defaults to 0. | |
shipping | integer | Shipping already included in amount, between zero and amount. Defaults to 0. | |
taxRate | number | Order-wide VAT percentage, such as 21 or 5.5. Non-negative. | |
taxBreakdown | array | VAT grouped by rate. A nonempty array cannot accompany taxRate. | |
items | array | Display-only order items. Does not determine the charge total. | |
customer | object | Customer email, billing address, and shipping address. |
The session charges in the currency you set. Supported Currencies lists every
currency Tapaya supports, but a merchant is usually enabled for only some of them. Creating a session in a
currency the merchant or backend does not support is rejected, so no hosted page is created.
The API charges amount as supplied. It does not add shipping or tax, calculate VAT from a rate, or calculate a
total from items.
Responses:
| Code | Description |
|---|---|
200 | Session created, or the original response replayed for a repeated key and body |
409 | Conflict: the key was reused with a changed body, or a request with the key is still processing |
Response body:
{
"id": "cs_7Hq2x9LmR4",
"merchantOrderId": "order-1001",
"url": "https://checkout.tapaya.com/c/cs_7Hq2x9LmR4",
"status": "open",
"paymentStatus": "unpaid",
"amount": 12100,
"currency": "EUR",
"tax": 2100,
"shipping": 605,
"taxRate": 21,
"taxBreakdown": [],
"items": [],
"expiresAt": "2026-07-15T12:30:00Z",
"createdAt": "2026-07-15T12:00:00Z"
}taxRate is included only when supplied. Store the id with your order, then send the browser to url with
HTTP 303. New sessions expire 30 minutes after creation. Return URLs are selected and validated at creation,
using either the request values or the merchant defaults.
Retrieve a Session
When the customer returns to your success or cancel URL, or from a reconciliation job, retrieve the session and compare it with the stored order before fulfilling.
Endpoint: GET /merchant/checkout-sessions/{id}
curl "$TAPAYA_CHECKOUT_API_URL/merchant/checkout-sessions/cs_7Hq2x9LmR4" \
-H "Authorization: Bearer $TAPAYA_CHECKOUT_API_KEY"There is no /status suffix. The response carries the session identity, URL, totals, tax fields, states, and
timestamps, plus nullable paymentReference and completedAt. paymentReference identifies the latest
confirmation attempt and is null before an attempt exists. A non-null reference does not prove success.
Timestamps are ISO 8601 strings.
Session status:
status | Meaning |
|---|---|
open | Session is available for payment, subject to expiry and merchant settings. |
processing | A payment attempt is in progress. |
completed | Session has completed. Check paymentStatus for the payment result. |
expired | Session is no longer available for a new payment. |
Payment status:
paymentStatus | Meaning for the order |
|---|---|
unpaid | No confirmed successful payment. The result may still be pending. |
successful | Payment succeeded. Reconcile order reference, amount, and currency before fulfillment. |
failed | Payment failed. Another card attempt is possible while the session remains open and unexpired. |
cancelled | Payment was cancelled. |
refunded | Payment was refunded. |
action_needed | Further action is required. Do not fulfill as paid. |
A declined card can leave status as open and paymentStatus as failed. Following the hosted page's cancel
link is navigation to cancelUrl; it does not itself prove a cancelled payment state.
Verify on your server
Fulfill only when the retrieved session matches your stored order's reference, amount, and currency and
paymentStatus is successful. A browser redirect alone never proves payment.
Order and payment ownership
Your server owns the order reference, prices, currency, and fulfillment state. Tapaya owns the checkout session and gateway payment result.
A checkout session ID identifies a hosted checkout. Its merchantOrderId links it to your order, while
paymentReference identifies the latest confirmation attempt. These values have different purposes. Store the
session ID with the order so you can retrieve the result even if the customer closes the browser.
The hosted page uses separate public endpoints to load and confirm the session. Its session ID is an access credential for those endpoints. A merchant integration verifies payment through the authenticated merchant endpoint.
Idempotency and errors
Creation requires a nonblank Idempotency-Key of at most 255 characters. A completed request with the same key and
body replays its response. Reusing the key with a changed body returns HTTP 409. A request still being processed also
returns HTTP 409.
Invalid totals, unsupported currencies, missing gateway configuration, disabled Checkout, or invalid redirect destinations reject creation. A card decline is a payment outcome, not proof that an HTTP request failed.
A network error or timeout leaves the payment outcome unknown until reconciliation.