payment-gateway-sandboxes
Overview
Every major payment gateway ships the same four sandbox primitives, each under
a different name:
- Test credentials - a sandbox API key / merchant account that can never
move real money.
- An environment switch - a sandbox base URL or an SDK
environment
flag that routes calls to the test stack.
- A deterministic test-card matrix - specific PANs (or amounts) that
trigger specific outcomes: success, decline, 3DS challenge.
- A webhook simulator / resend surface - a way to fire or replay
asynchronous events at your handler on demand.
This skill is the single entry point for the non-Stripe gateways. The body
covers the shared pattern; the per-gateway mechanics live in references/.
Routing table
| Gateway |
Reference |
Distinctive sandbox trait |
| Adyen |
references/adyen.md |
Explicit sync-API / async-notification duality; HMAC-validated notifications |
| PayPal |
references/paypal.md |
Sandbox Business + Personal accounts; dashboard + API webhook simulator |
| Braintree |
references/braintree.md |
Amount-based magic values; sandbox-only gateway.testing.settle |
| Stripe |
stripe-test-cards-and-webhooks |
Stripe CLI (stripe listen / stripe trigger); test clocks in stripe-subscription-billing-test-author |
When to use
- Authoring tests for code integrated with Adyen, PayPal, or Braintree.
- Wiring a gateway sandbox into CI (credentials, env switch, webhook secrets).
- Porting an existing single-gateway suite to a second gateway.
The shared sandbox test pattern
Regardless of gateway, a payment integration suite has the same skeleton:
- Initialize the SDK against the sandbox environment - never a prod
key; the environment switch is an env var, not a hardcode.
- Drive each documented test-card outcome - one test per outcome row
(success, decline variants, 3DS frictionless, 3DS challenge), asserting
the gateway's own result-code vocabulary.
- Verify webhook signatures - every gateway signs its events
(HMAC-SHA256 for Adyen, SHA256-with-RSA for PayPal,
bt_signature
parsing for Braintree); the suite must reject unsigned and wrong-secret
payloads.
- Prove handler idempotency under redelivery - all three gateways
redeliver unacknowledged events; process-exactly-once is the contract.
The full replay workflow is
payment-flow-test-author.
- Map the state machine - each gateway names the same lifecycle
differently; translate via
payment-flow-test-author (its payment-states reference) before
asserting on states.
CI integration
Sandbox credentials are secrets like any other:
jobs:
gateway-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
- run: npm ci && npm test
env:
ADYEN_TEST_API_KEY: ${{ secrets.ADYEN_TEST_API_KEY }}
PAYPAL_SANDBOX_CLIENT_ID: ${{ secrets.PAYPAL_SANDBOX_CLIENT_ID }}
BT_SANDBOX_MERCHANT_ID: ${{ secrets.BT_SANDBOX_MERCHANT_ID }}
Per-gateway variable lists are in each reference.
Anti-patterns
| Anti-pattern |
Why it fails |
Fix |
| Prod credentials in tests |
Real settlement / real charges |
Sandbox-only keys, per-env config |
| Skip webhook signature validation |
Spoofed events trigger fulfillment |
Verify per the gateway's scheme |
| Treat the sync API return as final |
All three gateways finalize async |
Webhook-driven state, per payment-flow-test-author (its payment-states reference) |
| One happy-path test |
Decline / 3DS / fraud paths untested |
One test per documented outcome row |
| Hardcoded merchant/account IDs |
Per-env accounts drift |
Env vars |
| One suite for all gateways |
Result-code vocabularies differ |
Per-gateway test directory |
Limitations
- Sandbox fidelity varies. Braintree settles synchronously via a
test-only API; prod settles overnight. PayPal sandbox webhooks can lag.
- Client-side surfaces need a browser. Drop-in / Hosted Fields /
PayPal-button flows require Playwright against the sandbox UI.
- Region-specific payment methods (iDEAL, Sofort, etc.) have separate
test flows not covered here.
References
- Adyen test mode, test cards, result codes, HMAC notifications:
references/adyen.md.
- PayPal Sandbox accounts, Orders v2, webhook simulator:
references/paypal.md.
- Braintree sandbox, amount-based magic values, webhook parser:
references/braintree.md.
- Companion catalog:
payment-flow-test-author (its payment-states reference: state machines + 3DS
flows).
- Flow suites on top of the sandboxes:
payment-flow-test-author.
- Stripe:
stripe-test-cards-and-webhooks,
stripe-subscription-billing-test-author.
1---2name: payment-gateway-sandboxes3description: "Use when code integrated with Adyen, PayPal or Braintree needs tests in sandbox mode: test credentials, sandbox URLs, deterministic test card numbers and each gateway's webhook simulator. For Stripe use stripe-test-cards-and-webhooks or stripe-subscription-billing-test-author."4metadata:5 source: https://skillmd.com/skills/testland/payment-gateway-sandboxes6---78# payment-gateway-sandboxes910## Overview1112Every major payment gateway ships the same four sandbox primitives, each under13a different name:14151. **Test credentials** - a sandbox API key / merchant account that can never16 move real money.172. **An environment switch** - a sandbox base URL or an SDK `environment`18 flag that routes calls to the test stack.193. **A deterministic test-card matrix** - specific PANs (or amounts) that20 trigger specific outcomes: success, decline, 3DS challenge.214. **A webhook simulator / resend surface** - a way to fire or replay22 asynchronous events at your handler on demand.2324This skill is the single entry point for the non-Stripe gateways. The body25covers the shared pattern; the per-gateway mechanics live in references/.2627## Routing table2829| Gateway | Reference | Distinctive sandbox trait |30|---|---|---|31| Adyen | [references/adyen.md](references/adyen.md) | Explicit sync-API / async-notification duality; HMAC-validated notifications |32| PayPal | [references/paypal.md](references/paypal.md) | Sandbox Business + Personal accounts; dashboard + API webhook simulator |33| Braintree | [references/braintree.md](references/braintree.md) | Amount-based magic values; sandbox-only `gateway.testing.settle` |34| Stripe | `stripe-test-cards-and-webhooks` | Stripe CLI (`stripe listen` / `stripe trigger`); test clocks in `stripe-subscription-billing-test-author` |3536## When to use3738- Authoring tests for code integrated with Adyen, PayPal, or Braintree.39- Wiring a gateway sandbox into CI (credentials, env switch, webhook secrets).40- Porting an existing single-gateway suite to a second gateway.4142## The shared sandbox test pattern4344Regardless of gateway, a payment integration suite has the same skeleton:45461. **Initialize the SDK against the sandbox environment** - never a prod47 key; the environment switch is an env var, not a hardcode.482. **Drive each documented test-card outcome** - one test per outcome row49 (success, decline variants, 3DS frictionless, 3DS challenge), asserting50 the gateway's own result-code vocabulary.513. **Verify webhook signatures** - every gateway signs its events52 (HMAC-SHA256 for Adyen, SHA256-with-RSA for PayPal, `bt_signature`53 parsing for Braintree); the suite must reject unsigned and wrong-secret54 payloads.554. **Prove handler idempotency under redelivery** - all three gateways56 redeliver unacknowledged events; process-exactly-once is the contract.57 The full replay workflow is `payment-flow-test-author`.585. **Map the state machine** - each gateway names the same lifecycle59 differently; translate via `payment-flow-test-author` (its payment-states reference) before60 asserting on states.6162## CI integration6364Sandbox credentials are secrets like any other:6566```yaml67jobs:68 gateway-tests:69 runs-on: ubuntu-latest70 steps:71 - uses: actions/checkout@v572 - uses: actions/setup-node@v473 - run: npm ci && npm test74 env:75 ADYEN_TEST_API_KEY: ${{ secrets.ADYEN_TEST_API_KEY }}76 PAYPAL_SANDBOX_CLIENT_ID: ${{ secrets.PAYPAL_SANDBOX_CLIENT_ID }}77 BT_SANDBOX_MERCHANT_ID: ${{ secrets.BT_SANDBOX_MERCHANT_ID }}78```7980Per-gateway variable lists are in each reference.8182## Anti-patterns8384| Anti-pattern | Why it fails | Fix |85|---|---|---|86| Prod credentials in tests | Real settlement / real charges | Sandbox-only keys, per-env config |87| Skip webhook signature validation | Spoofed events trigger fulfillment | Verify per the gateway's scheme |88| Treat the sync API return as final | All three gateways finalize async | Webhook-driven state, per `payment-flow-test-author` (its payment-states reference) |89| One happy-path test | Decline / 3DS / fraud paths untested | One test per documented outcome row |90| Hardcoded merchant/account IDs | Per-env accounts drift | Env vars |91| One suite for all gateways | Result-code vocabularies differ | Per-gateway test directory |9293## Limitations9495- **Sandbox fidelity varies.** Braintree settles synchronously via a96 test-only API; prod settles overnight. PayPal sandbox webhooks can lag.97- **Client-side surfaces need a browser.** Drop-in / Hosted Fields /98 PayPal-button flows require Playwright against the sandbox UI.99- **Region-specific payment methods** (iDEAL, Sofort, etc.) have separate100 test flows not covered here.101102## References103104- Adyen test mode, test cards, result codes, HMAC notifications:105 [references/adyen.md](references/adyen.md).106- PayPal Sandbox accounts, Orders v2, webhook simulator:107 [references/paypal.md](references/paypal.md).108- Braintree sandbox, amount-based magic values, webhook parser:109 [references/braintree.md](references/braintree.md).110- Companion catalog: `payment-flow-test-author` (its payment-states reference: state machines + 3DS111 flows).112- Flow suites on top of the sandboxes: `payment-flow-test-author`.113- Stripe: `stripe-test-cards-and-webhooks`,114 `stripe-subscription-billing-test-author`.