Test / Sandbox Mode
You can build and test the full integration without moving real money.
Two ingredients
- A test token (
cp_test_…) issued by an admin. Payments created with it are flagged"test": trueand are excluded from production statistics. - A sandbox gateway configured as your application's default gateway. A test token refuses to work with a live gateway (
GATEWAY_NOT_CONFIGURED), so you can never accidentally hit a real merchant account from a test environment.
Two kinds of sandbox gateway exist:
| Gateway | Behaviour |
|---|---|
Sandbox simulator (fake driver) |
Built into Cartino Pay. payment_url points to a simulator page on Cartino Pay itself with Pay / Cancel / Fail buttons. No external calls at all. Perfect for CI and local development. |
Gateway sandbox (e.g. Zarinpal sandbox, Zibal with the zibal test merchant) |
Real provider sandbox; exercises the provider's own pages. Use before going live. |
Typical setup
| Environment | Application | Token | Default gateway |
|---|---|---|---|
| Local / CI | cartino-cloud-dev |
cp_test_… |
Sandbox simulator |
| Staging | cartino-cloud-staging |
cp_test_… |
Zarinpal sandbox |
| Production | cartino-cloud |
cp_live_… |
Zarinpal live |
Because gateways are configured per application, the same code runs in every environment; only the token and base URL differ.
Driving the simulator
POST /api/v1/payments→payment_urllikehttps://pay.cartino.net/sandbox/pay/FAKE…- Open it. Click Pay → you are redirected to your
callback_url?…&status=paidand apayment.paidwebhook is sent. Cancel →cancelled. Fail →failed. - For automated tests, POST the simulator's form directly:
POST https://pay.cartino.net/callbacks/{gateway-slug}?p={payment_id}withauthority=<value from the simulator page>andstatus=OK|CANCEL|FAIL.
Receiving webhooks locally
Expose your local server with a tunnel (e.g. ngrok http 8000) and ask an admin to set the tunnel URL as the webhook URL of your dev application. Webhook secrets and signatures behave exactly as in production.
Going live checklist
- Live token stored in the production secret manager
- Production callback URL(s) registered (https)
- Production webhook URL registered and signature verification tested
- Default gateway switched to a live gateway by an admin
- Reconciliation job (verify pending payments) running
- Test-token and live-token environments never share configuration