{"object":"doc","slug":"sandbox","title":"How the sandbox works","summary":"What is real and what is simulated with a test key, how simulated terminals behave, and how to exercise every outcome.","tags":["concept","sandbox","testing"],"body":"# How the sandbox works\n\nWith a `zp_test_` key:\n\n| Capability | In the sandbox |\n|---|---|\n| Merchants | Created instantly, `processor_connected` true when a sandbox processor account is configured |\n| Simulated terminals | Fully local; you pick the outcome |\n| Physical terminals | Real discovery, registration, push, and callbacks against the sandbox processor account, reserved for listed platforms (the shared account has one demo terminal); everyone else uses simulated terminals |\n| Keyed payments | Real calls to the processor sandbox with test cards |\n| Refunds, voids | Local for simulated payments; real sandbox calls for keyed ones |\n| Webhooks, events, idempotency | Identical to live |\n\n## Simulated terminals\n\n`sim_behavior` decides who answers:\n- `manual` (default): nothing happens until you call `POST /v1/sandbox/terminals/{terminal_id}/simulate` with `approve`, `decline`, `cancel`, or `timeout`.\n- `auto_approve` / `auto_decline`: the terminal answers on its own `sim_delay_s` seconds after the payment is created (0 to 30 s). Use a delay to test your \"waiting for the customer\" UI.\n\nA simulated approval reports card `visa` ending `4242`. Every outcome emits the same events a physical terminal would.\n\n## Keyed test cards\n\nThe sandbox decides by card number, not by amount or by the name and ZIP on the form. `collect-config` returns the same list as `test_cards`.\n\n| Card | Expiry, CVV | Result |\n|---|---|---|\n| `4761739001010010` (Visa) | any future MM/YY (type the slash), any 3 digits | `state: succeeded`, `card_last4: 0010`, a real `processor_transaction_id`; `POST /v1/payments/{id}/void` reverses it the same day, and so does a refund (see below) |\n| `4111111111111111` (Visa) | any | `state: failed`, `failure_code: card_declined` |\n| `4242424242424242` (Visa) | any | `state: failed`, `failure_code: card_declined` |\n\nVerified 2026-09-06 on the hosted sandbox. A decline is still a `201` with the payment in `failed`, exactly as in live mode. A reused or expired nonce comes back `failure_code: nonce_invalid` instead, which exercises the same failed-state handling.\n\nProcessor behaviour, VERIFIED 10/18/2026 through the hosted form: `4111111111111111` tokenizes without error and is declined at the sale with the reason RISK DECLINED, so the decline arrives as a payment result, not as a form error. The mock processor reuses approval codes across sales and merchants and reports the same batch id on every sale, so never key anything on either.\n\nRepeated sales, VERIFIED 10/28/2026 on the sandbox processor: a second sale on the same card for the same amount about 2 seconds after a captured one is declined by the processor's duplicate screen, even with a new `Idempotency-Key` and a new `platform_reference`. It arrives as `state: failed`, `failure_code: card_declined` on the approving card `4761739001010010`, with no `processor_transaction_id`. The length of that window is unmeasured. When a test needs several approved keyed sales in a row, give each a different `amount_cents`. The errors guide (\"The processor's duplicate screen\") has the processor's answer.\n\nRefunds before settlement: the sandbox processor accepts a refund of a sale that has not settled yet and returns the refund's own `processor_transaction_id`, for keyed sales (VERIFIED 11/02/2026) and for card-present terminal sales (VERIFIED 11/16/2026 on the dev Smart Terminal), so `409 not_settled_use_void` has not been seen in the sandbox. Production behaviour is unverified. Code the `not_settled_use_void` branch from the refunds guide anyway: it remains possible on other processor setups and is still handled. To exercise a void in the sandbox, void a simulated-terminal payment or a keyed sale before refunding any of it.\n\n## Test card tokens (no browser)\n\nIn test mode you can skip the card form. Name a test card token where the form's one-time value goes, and ZeroPoint answers for the processor itself: nothing reaches GoDaddy, no money moves, and no card number is ever sent.\n\n| Token | Card | Every charge of it |\n|---|---|---|\n| `tok_visa` | Visa 0010, expiry 12/2034 | approved |\n| `tok_chargeDeclined` | Visa 1111 | declined, `decline_code: do_not_honor` |\n| `tok_chargeDeclinedInsufficientFunds` | Visa 9995 | declined, `insufficient_funds` |\n| `tok_chargeDeclinedLostCard` | Visa 9987 | declined, `lost_card` (a hard decline: billing blocks the card for later invoices; a card on file payment only declines) |\n| `tok_chargeDeclinedStolenCard` | Visa 9979 | declined, `stolen_card` (a hard decline, as above) |\n\nTwo places take them:\n\n- Save a card: `POST /v1/payment_methods` with `\"nonce\": \"tok_visa\"` (MCP `save_payment_method`). The card is saved with no charge and is then charged like any saved card: card on file payments, subscriptions, invoices, renewals on a test clock. A token is a reusable name, not a one-time value: save `tok_visa` for as many customers as you need, over REST or MCP. Each REST save makes a new card; over MCP (`save_payment_method`, which takes no key) each customer's first save makes its card and the same customer saving `tok_visa` again gets that card back.\n- Pay a hosted checkout session: `POST /v1/test_helpers/checkout/sessions/{session_id}/confirm` with `{\"card\": \"tok_visa\", \"email\": \"buyer@example.com\"}` and an `Idempotency-Key` (MCP `confirm_checkout_session`). It does what a buyer pressing Pay on the session's `url` does, in payment and subscription mode, under every rule of the page (the duplicate subscription guard, the attempt ceiling, holds). `email` is the address the buyer would type on the page: it is needed when the session names no email (no `customer_email`, and no `customer` with an email), else `400 parameter_missing`; otherwise the session's email is used and the one sent is ignored. It answers the session with `status: complete`; a decline answers `402` with the payment's code and `decline_code`, and the session stays open for another card. When the merchant's duplicate subscription guard refuses the purchase it answers `409 checkout_subscription_refused`, the page's own refusal (\"We could not start this subscription. Nothing was charged...\"): nothing is charged, the session's `duplicate_refusal` says why, and the session expires after 3 such refusals, or at once when the buyer completed the plan elsewhere ([Hosted checkout](checkout.md)).\n\nWhat you get is what a typed card makes: the same payment, saved card, customer, subscription, invoice, events and webhooks, in the same order, so code written against the tokens works unchanged when a person types a card. The one mark: the `processor_transaction_id` of such a payment or refund starts `zp_test_txn_`. Its refunds and voids are answered the same way, also after a restart of the service (a read by id of an old helper transaction then answers not found). A helper sale never settles, so a void of it is never refused as `settled_use_refund`: that answer cannot be produced with the tokens. To make a later renewal of a `tok_visa` card fail, use `fail_next_charges` (`test-billing-with-test-clocks`).\n\nRules: test mode only (a live key gets `400 test_mode_only`, and through MCP `live_mode_unavailable`; a test key does not see a live merchant's session or customer, `404 resource_missing`; a test card token with a live merchant on the save is `400 test_mode_only`). Only the five names: any other `tok_` value, and any card number, is `400 parameter_invalid`. In test mode `POST /v1/payments`, the hosted page and the portal's card update do not take a token (`400 parameter_invalid`): save the card, then charge its `pm_` id. In live mode a token is not special there: it is sent as an ordinary nonce and the processor refuses it. The sandbox processor must be set up, as for every save (`503 sandbox_processor_unconfigured`). Stripe's `tok_chargeDeclined` is refused when it is attached to a customer; here the card saves and every charge of it declines, as GoDaddy's sandbox card `4111111111111111` does.\n\nA test card token skips the card form and the processor entirely, so a flow proven with tokens does not prove that your card form embed, the hosted page in a browser or live processing work. Before going live, run at least one payment in test mode with a typed card on the real form (`4761739001010010`, the `first_keyed_payment` step).\n\n## Hosted card form\n\nThe page at `sandbox_form_url` (from `collect-config`) embeds the same hosted form your checkout embeds (`form_url` in an iframe, a `message` listener for `zeropoint.nonce`), so you can get a nonce and try a charge before you have wired up a page of your own, and see the exact messages your page will receive. Verified 2026-09-06 on the hosted service: the form reaches \"ready\" with no script errors.\n\n## Saved cards\n\nA card saved from a test card token (above) is answered by ZeroPoint and never reaches the processor. Every other save in test mode calls the sandbox processor's real save (tokenize), and every charge of such a card calls its real sale: a merchant on the shared sandbox account under ZeroPoint's own processor credentials, a test merchant connected to its own processor test account under that merchant's credentials. The simulated terminal plays no part and never produces a saved card. Without a token, a person types a test card into the save form (`save_form_url`) in an ordinary browser and your app saves the nonce; after that the card can be charged with no browser. Deleting a saved card calls no processor. Refunds and voids of a saved-card payment go to the sandbox processor. With no sandbox processor account, saving, saving with a payment, and charging a saved card answer `503 sandbox_processor_unconfigured`; customers work without one. See `save-a-card`.\n\n## Daily limits and retention\n\nThe sandbox is shared, so test mode has ceilings that live mode does not. Each platform can create 1,000 test payments and 2,000 test events per UTC day, far above what integration testing needs, and all sandbox platforms together share a larger daily event allowance. Past any of them, a new test payment answers `409` with code `sandbox_daily_limit_exceeded`; past an event ceiling, `POST /v1/webhooks/{id}/test` and the webhook scorecard do too, and so does a new test refund or void (a retry of a refund already in progress is never refused). Honor `Retry-After`: the count resets at 00:00 UTC. Payments already in flight still finish and still emit their events.\n\nTest events and their webhook deliveries are kept for 14 days and then deleted. After that `GET /v1/events/{id}` answers `resource_missing` for them and they no longer appear in `GET /v1/events`. Test payments and refunds are kept. Live events are never deleted.\n\n## Isolation\n\nEvery object is scoped to the platform that created it. Another platform's key gets `resource_missing` for your ids, even in the shared sandbox account.","updated":1795275945}