Skip to content

Test Cards

Visa

Use this card to simulate a successful payment:

FieldValue
Number4111 1111 1111 1111
ExpiryAny future date (e.g. 12/30)
CVCAny 3 digits (e.g. 123)

Card brand detection

The widget detects the card brand from the card number prefix:

BrandNumber prefix
Visa4
Mastercard5155
American Express34, 37
Discover6011, 65
Diners Club36, 38
JCB35

BECS direct debit test accounts

For Australian bank account (BECS) payments:

FieldValue
BSB062-000
Account numberAny number
Account nameAny name

Forcing payment outcomes

To force a specific outcome regardless of card details, set _sandbox_outcome in the payment intent’s metadata:

Terminal window
curl -X POST https://api.elasticpay.co/api/v1/payment_intents \
-H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"amount": 1999,
"currency": "AUD",
"metadata": {"_sandbox_outcome": "decline"}
}'
ValueResult
succeedPayment succeeds (the default without an override)
declinePayment fails with insufficient_funds
requires_actionSimulates a 3D Secure challenge
timeoutPayment fails with gateway_timeout

This works for any payment method and takes priority over card-number-based outcomes. Refunds have a parallel override — set "_sandbox_refund_outcome": "fail" in the refund request’s metadata to make the refund fail (refunds succeed by default).

Fixture tokens — server-side testing without the widget

For CI pipelines, server-side tests, and agents, you can skip the widget entirely: pass a fixture token as token_metadata.token when creating a payment method (sandbox keys only).

Terminal window
curl -X POST https://api.elasticpay.co/api/v1/payment_methods \
-H "Authorization: Bearer pk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"type": "card",
"payment_method_data": {
"token_metadata": {
"type": "fixture",
"token": "tok_sandbox_visa_succeed",
"data": ""
}
}
}'
TokenBrandlast4Outcome when charged
tok_sandbox_visa_succeedVisa4242Succeeds
tok_sandbox_visa_decline_insufficient_fundsVisa0002Declines — insufficient funds
tok_sandbox_visa_decline_card_lostVisa9987Declines — card lost
tok_sandbox_visa_3ds_requiredVisa3155Requires 3D Secure authentication
tok_sandbox_visa_timeoutVisa0119Fails — gateway timeout
tok_sandbox_mastercard_succeedMastercard4444Succeeds
tok_sandbox_amex_succeedAmex8431Succeeds

The outcome travels with the saved payment method: every later charge against it resolves to that outcome, regardless of amount. That makes the declining tokens the right tool for testing recurring-billing failure handling — save a declining card, attach a payment plan, and advance a test clock to watch the dunning flow run.

Amount-based outcomes

When no metadata override or fixture outcome applies, the last two digits of the amount in cents select the outcome:

Amount ends inOutcome
01Declines — insufficient funds
02Requires 3D Secure authentication
99Fails — gateway timeout
anything elseSucceeds

For refunds, an amount ending in 03 fails; anything else succeeds.

Prefer _sandbox_outcome metadata or fixture tokens — they leave amounts free to carry realistic values, so a $19.99 subscription in a test stays $19.99. Watch for accidental triggers: a test amount of 1001 cents declines by design.

Outcome precedence

  1. _sandbox_outcome in the payment intent’s metadata (per-charge override)
  2. The saved payment method’s fixture outcome
  3. Amount-based fallback
  4. Default: succeed

Notes

All test transactions use mocked PSP responses. Webhook events still fire normally in sandbox mode, giving you a realistic integration test environment.