# Testing

URL: https://doc.securepayapi.com/testing
Last updated: 2026-11-12

> Validate your integration before you start taking real payments.

Make sure your integration behaves correctly — creating a Payment Intent,
loading the widget, and handling the result — before you rely on it in
production.

> **Note:**
Use **[Sandbox](https://doc.securepayapi.com/sandbox)** to test the whole flow — invoices, products and the
widget — without moving real money. Flip your dashboard to Sandbox, or create the
Payment Intent with `mode: 'sandbox'` (it is set when the intent is created, not
in the widget). The checks below still apply to your integration logic.

## What to check

- Your server creates a Payment Intent and receives a `client_secret`.
- The widget loads on your domain and accepts the `client_secret`.
- You correctly handle the `success` and `error`
  [messages](https://doc.securepayapi.com/embedded-checkout) from the widget — including
  `status: "pending"`, which must **not** lead to a second payment.
- You resize the iframe in response to `resize` messages (the SDK does this for
  you).
- Your server [reads the intent back](https://doc.securepayapi.com/payment-intents#confirm-the-payment-on-your-server)
  and checks status, amount, currency and `mode` before fulfilling — never on the
  browser's word alone.
- The customer sees the [3-D Secure](https://doc.securepayapi.com/authentication-3ds) prompt when their bank
  requires one, and the flow completes either way.
- For a [subscription](https://doc.securepayapi.com/payment-intents#recurring-payments-subscriptions): the
  widget shows the terms and requires the checkbox, `success` carries
  `subscription.status: "pending_activation"`, and your server waits for the
  agreement to become active before granting access.
- A card declined at the charge leaves the intent `failed`; one that fails or
  is abandoned earlier, in 3-D Secure, leaves it `requires_payment`. Either way
  nothing was taken and the customer can retry. A declined wallet payment
  arrives as `payment_ended { outcome: "failed" }` and then an `error` with a
  `reference`, and leaves the intent `requires_payment`; the intent's
  `last_attempt` may describe it once the widget has prepared the next wallet
  attempt, so do not depend on it being there. A closed wallet sheet posts only
  `payment_ended { outcome: "cancelled" }`.
- Your server never reads `requires_payment` or `failed` as paid, and never
  reads `processing` as unpaid.
- If your checkout creates the order before charging: an empty card form is
  caught by [`validate()`](https://doc.securepayapi.com/sdk#handlevalidate) and no order is created.
- Your page honours `onActive` / `payment_started`: a cart edit while a payment
  is active is queued, never applied by remounting the widget.
- A second `submit()` while one is pending rejects with "A payment is already in
  progress."; a page on an unregistered host (or an unregistered port) gets
  `origin_not_allowed`. A wrong publishable key produces no callback at all —
  the frame answers 404 — so treat a widget that never reaches `onReady` as a
  wiring problem.
- If you use [wallets under your own button](https://doc.securepayapi.com/sdk#wallets-under-your-own-button):
  returning anything but `true` from `onWalletAuthorize`, or answering too late
  (18 s Apple Pay, 30 s Google Pay), ends with
  `payment_ended { outcome: "cancelled" }`, nothing charged — and your server
  handles the order it created for that attempt.
- Your reconciliation covers the known Google Pay issue: an intent that stays
  `requires_payment` after the customer approved a wallet payment is checked
  against the transaction
  (`GET https://app.securepayapi.com/api/v1/transactions/{transaction_reference}`)
  or the dashboard before you ask for another payment. See
  [3-D Secure](https://doc.securepayapi.com/authentication-3ds#wallets).

Pay with the [test cards](https://doc.securepayapi.com/sandbox#test-cards) in sandbox for each of these.

## Discount codes

If you use coupons on a [hosted checkout](https://doc.securepayapi.com/hosted-checkout) page, enter a code
and confirm the total updates correctly before payment. Manage your codes per
product in [Products & pricing](https://doc.securepayapi.com/products).

## Going live

Once your integration handles the full flow cleanly, you're ready to take real
payments. Keep your [secret key](https://doc.securepayapi.com/api-keys) server-side and monitor your first
live transactions from your [dashboard](https://app.securepayapi.com/).
