Skip to main content

Create payment

Create a payment (hosted checkout session) and get a URL to redirect the customer.

Endpoint

POST /checkout/create/

Authentication: Required (API key with checkout:create scope).

Request body

FieldTypeRequiredDescription
billing_countrystringYesISO 3166-1 alpha-2 (e.g. US, FR)
billing_postal_codestringYes if USRequired when billing_country is US
billing_first_namestringYes
billing_last_namestringYes
billing_emailstringYesEmail address
billing_phonestringNo
currencystringYesUSD or EUR
productsarrayYesSee Products below
successUrlstringNoRedirect URL after successful payment
failedUrlstringNoRedirect URL after failed payment
cancelUrlstringNoRedirect URL when customer cancels

Products

Each item in products is either:

By product ID (from your catalog):

{ "id": "prod_xxx", "quantity": 1 }

By name and price (ad-hoc; only if your organization allows):

{ "name": "Premium Plan", "quantity": 1, "unit_price": 29.99 }
  • id — Your product's public ID. Name and unit_price are optional (loaded from DB).
  • name + unit_price + quantity — Required when not using id. unit_price must be positive.

Response (201)

{
"checkout_id": "org1-1234567890-abc123",
"order_id": "org1-1234567890-abc123",
"checkout_url": "https://...",
"token": "...",
"expires_at": 1234567890
}
FieldDescription
checkout_idStable ID — store this to link with payment webhooks. Same as order_id.
order_idUnique per checkout. The webhook payload includes order_id so you can match transactions to your checkouts.
checkout_urlRedirect the customer here to complete payment.
tokenSigned token for the checkout URL. Prefer checkout_id for storage — token is long and meant for redirects.
expires_atUnix timestamp; the checkout is valid until this time.

Example

curl -X POST "https://api.sandbox.nd8.com/api/checkout/create/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"billing_country": "US",
"billing_postal_code": "10001",
"billing_first_name": "Jane",
"billing_last_name": "Doe",
"billing_email": "jane@example.com",
"currency": "USD",
"products": [{"id": "prod_abc123", "quantity": 2}],
"successUrl": "https://myshop.com/success",
"failedUrl": "https://myshop.com/failed"
}'