Lesson 4 — Force outcomes with magic values

Tests must be deterministic. In test mode, magic values are fixed inputs

that force a specific outcome — no real money, no real rails, no flaky tests.

The cheatsheet

InputOutcome
reference: "test_success" or amount 1succeeded
reference: "test_fail" or amount 2failed
reference: "test_pending"processing, then succeeds on the next simulate
any other reference/amountsucceeded
MyCash OTP 000000fails with otp_incorrect (any other OTP approves)
MyCash mobile +679 999 7888rejected (invalid_mobile)
bank account ending 0000disbursement bounces

Simulate from anywhere

You can drive an intent to its forced outcome without a redirect — useful in

CI. Either call the endpoint directly:


curl -X POST https://api.transxact.io/simulate/pi_...

or use the one-click Simulate box in the magic-values card of the

Developer section.

A deterministic test loop


# always succeeds
curl https://api.transxact.io/payment-intents \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{ "amount": 100, "reference": "test_success" }'

curl -X POST https://api.transxact.io/simulate/pi_...
# → { "intent": { "status": "succeeded", ... } }

The same pattern with test_fail exercises your failure path: mark the order

failed, notify the customer, release stock.

Exercise

1. Drive three intents to succeeded, failed, and processing using only

magic values.

2. For the processing intent, simulate a second time and watch it resolve.

3. Break something on purpose: use the magic mobile +679 999 7888 on a

MyCash confirm and handle the error object in your code.

What's next

Payments emit signed webhooks at every transition.

Lesson 5 makes your server listen.