# Test mode

Test mode is a complete sandbox. Use it to build and test your integration without real money.

## What is separate
- Keys: `sk_test_…` / `pk_test_…` only see test data; live keys only see live data.
- Wallets, apps, payments, payment links and webhooks are separate per mode.
- Test mode works even without an active subscription.
- Every object has `"livemode": false`.

The dashboard has a **Live / Test** switch in the top bar; a yellow banner shows while you are in test mode.

## Simulating outcomes
Test payments never touch a blockchain. Create a payment, open its checkout (or quote it with the API),
then move it to a final state:
```bash
curl https://razcryptogateway.com/v1/payments/pay_…/simulate \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"outcome":"paid"}'
```
| `outcome` | Result |
|---|---|
| `paid` | Exact amount received and confirmed → `payment.paid` |
| `overpaid` | More than asked → `paid` with the `overpaid` flag |
| `underpaid` | Less than asked → `underpaid` (final after the grace period) |
| `expired` | Nothing received in time → `payment.expired` |
| `cancelled` | Cancelled → `payment.cancelled` |

Real, signed webhooks are delivered exactly like in live mode, so you can test your handler end to end.
You can also send a `test.ping` event from **API apps → your app → Send test event**.

## Checklist before going live
- Your webhook handler verifies the signature and is idempotent (the same event may arrive twice).
- You fulfil orders from the webhook (or a `GET /v1/payments/{id}` check), not from the browser alone.
- You handle `underpaid` and `expired` (for example, show "contact support" or let the customer retry).
- Secrets live in server environment variables.
