# Test cash scenarios

Pay, expire, refuse or suspend a test cash code, and see how your integration reacts to each outcome.

A test cash code cannot be paid at an agent. Instead, you decide what happens to it, in one of three
places:

* **Simulate payment** and the other buttons on the voucher page your customer sees, in test mode;
* the **test helpers** card on the payment's page in the dashboard, in test mode;
* the [test helpers API](https://pay-docs.adpromax.com/en/sandbox/test-helpers), for automated tests: `pay`, `expire`, `refuse` and
  `suspend` on the payment's attempt.

The outcome reaches the payment the way a live one does: through a status check on the simulated
network, then the state machine, the events and your webhook. After a simulated action the check
runs at once, so the result arrives within seconds.

## The scenarios

- **Paid** (`pay`): The payment succeeds: `payment_intent.succeeded`.

- **Paid another amount** (`pay` with an `amount` that differs): Nothing is credited: the payment stays `processing` with a `review` (`amount_mismatch`), and you receive `review.opened`.

- **Expired** (`expire`): The attempt ends `expired`; the payment goes back to `requires_payment_method` with `voucher_expired`.

- **Paid after expiry** (`expire`, then `pay`): Nothing is credited: a `review` (`paid_after_end`) and `review.opened`.

- **Refused by the network** (`refuse`): The attempt fails with `voucher_refused`; the payment goes back to `requires_payment_method`.

- **Suspended, then paid** (`suspend`, then `pay`): The payment waits while suspended, then succeeds.

- **Below 100 MAD** (A cash payment of 50.00 MAD (`5000`)): Refused with `amount_too_small`, as in live mode.

## The amount to pay

A voucher gives two amounts: your `amount`, and the `amount_to_pay` your customer hands over, which
adds a small stamp fee (in test mode, 0.25 MAD: `15000` becomes `15025`). Your customer pays the
fee; it is not taken from your `amount`. Show `amount_to_pay` as the voucher gives it.

To try **Paid another amount**, pass an `amount` clearly apart from the payment's, such as half of
it. Without an `amount`, `pay` pays the voucher in full.

## What each scenario teaches

* **Expired**: most unpaid codes end this way. Free the order or the stock, and let your customer
  get a new code.
* **Paid another amount** and **Paid after expiry**: money can arrive that does not match the
  payment. AdProMaxPay credits nothing by itself and a person looks at it; your code waits for
  `succeeded`, which may never come for this payment.
* **Suspended**: a code can be on hold for a while at the network. Your code has nothing to do but
  wait.

Card scenarios are in [Test cards](https://pay-docs.adpromax.com/en/sandbox/test-cards). How cash differs in live mode is in
[Sandbox and live: the differences](https://pay-docs.adpromax.com/en/sandbox/differences).
