Skip to main content

Checkout sandbox scenarios

Use this when you integrate hosted checkout with a sandbox API key and the sandbox base URL (same host as production, with a /sandbox/api/ path prefix — see Organization & merchant).

There are two ways to exercise outcomes:

  1. Scripted simulation (no real card) — when your deployment runs the internal simulation layer (internal test mode). You pass sandbox_simulate on POST /api/checkout/create/ (or POST /sandbox/api/checkout/create/) and complete the usual create → hosted page → create-nd8-payment → sync-status flow; the next GET payment–equivalent step returns a fixed provider status for that session.
  2. Provider sandbox — when the platform uses sandbox credentials, card behaviour is defined by the payment provider (test instruments, decline rules, etc.). Use the sandbox test instruments available in your environment; do not send sandbox_simulate unless your environment documents it as supported.

Optional field: sandbox_simulate

PropertyValue
WhereJSON body of POST /api/checkout/create/ (or under /sandbox/api/)
RequiresSandbox API key (environment: sandbox) + sandbox API base URL
Production keysField present → 400 Bad Request
Effect on paymentScripted GET payment responses only when the server uses internal simulation (e.g. automated tests). With a live provider sandbox, the field may be stored on the session but does not change the provider’s real status—use the provider’s own test instruments.

When simulation is active, allowed values are exactly:

sandbox_simulateSimulated provider outcomeTypical POST /api/checkout/sync-status/ statusMerchant wallet credited?
(omit field)PAYMENT_SUCCESS + depositStatus: succeededSUCCESSYes (same as happy path)
payment_failedPAYMENT_FAILEDFAILEDNo
checkout_canceledCHECKOUT_CANCELEDCANCELEDNo
canceledCANCELEDCANCELEDNo
success_pending_depositPAYMENT_SUCCESS + depositStatus: pendingSUCCESS (transaction may show paid; deposit not settled)No — waits for deposit before settlement rules apply
checkout_pendingCHECKOUT_PENDINGCHECKOUT_PENDINGNo — keep polling sync until a terminal state

Mapping to “real world” checks

  • Good card / paid — omit sandbox_simulate (or use the provider sandbox success path).
  • Declined / insufficient / issuer error — use payment_failed in simulation, or the matching provider sandbox decline in live sandbox mode.
  • Customer abandoned checkoutcheckout_canceled or canceled.
  • Authorized but not captured yetsuccess_pending_deposit.
  • Still at provider checkoutcheckout_pending (your client should keep calling sync until terminal).

Automated tests

Backend tests cover each scenario end-to-end:

cd backend && python manage.py test transactions.tests.test_checkout_sandbox_simulate -v 2