commerce

POST /v1/orders/{orderId}/top-up-and-pay

Add account credit with a saved card, then pay the whole order from credit.

All commerce endpoints

All developer docs →

Zinn®, our Viking, hammering at his anvil beside an API endpoint sending events to several listeners.

Authentication

Send an API key as a bearer token. The endpoint checks billing.payment.manage; a key without it is refused with 403, not 404.

This endpoint takes no organisation id. Your key already identifies the organisation it belongs to, and the response is scoped to it.

Try it

Replace anything in angle brackets with your own values, and the key placeholder with a key from your dashboard.

curl -X POST https://api.zinndigital.com/v1/orders/{orderId}/top-up-and-pay \
  -H "Authorization: Bearer zdk_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "amount_minor": <integer>, "idempotency_key": <string> }'

Signed in? The API console in your dashboard fills in your real organisation id and your own key, and runs the request against the live API so you can see the actual response. Open this endpoint in the API console

Details

When account credit covers part of an order, the customer may buy the missing credit instead of paying the remainder by card. ONE card charge happens here, the credit top-up (an untaxed voucher, like POST /v1/wallet/top-ups), idempotent on idempotency_key: a repeated key never charges again. Once the top-up is captured the order is paid from credit with payOrder's credit_only path in the same request (the order was taxed when it was placed). Offered only when getOrderPaymentOptions.top_up_and_pay is not null; amount_minor must be at least its amount_minor. When the bank asks for 3-D Secure the answer is 202 with the top-up's client_secret and publishable_key: run Stripe's handleNextAction, then send the SAME request again (same key) to pay.

Parameters

NameTypeRequiredWhat it is
orderId (path)UuidYesThe order's id.

Request body

NameTypeRequiredWhat it is
amount_minorintegerYesCredit to add, in the order's currency minor units; at least PaymentOptions.top_up_and_pay.amount_minor. Ignored on a repeated key (the first attempt's amount stands).
idempotency_keystringYesOne per press; send the same key again after a 3-D Secure check.
payment_method_idstringNoThe saved card to charge; omitted = the primary card.
renew_automaticallybooleanNoAs payOrder.renew_automatically; default true.

Response

NameTypeRequiredWhat it is
outcomestring<paid, requires_action, pending, failed>Yes—
orderOrderYes—
top_upClientWalletTopUp | nullYesThe credit top-up (null when the order was already paid).

Errors this endpoint can return

401 · 402 · 403 · 404 · 409 · 422 · 429