A sandbox test card works in test mode. Enter a processor-issued number in a checkout page that uses test API keys. The processor returns the result tied to that number.
How to Use a Sandbox Payment Test Card for Secure Testing
What a sandbox test card is
A sandbox test card is a card number that a payment processor issues for test mode. The processor maps the number to a result: approval, decline, or error code. The number has no bank account behind it. It cannot move money. It works when the account uses test API keys.
Where to get test card numbers
Each processor publishes a list. Use the list from the processor that runs your account. A number from one processor does not carry the same result in another.
- Stripe: 4242 4242 4242 4242 returns a charge with status succeeded. 4000 0000 0000 0002 returns a decline with code card_declined. Stripe accepts any expiry date after today, any 3-digit CVC, and any postal code for 4242 4242 4242 4242.
- Adyen: 4111 1111 1111 1111 returns a Visa approval. 5555 5555 5555 4444 returns a Mastercard approval. Use expiry 03/2030 and CVC 737.
- PayPal: create a sandbox personal account in the developer dashboard. PayPal assigns the card and balance to that account.
Steps to run a test payment
- Open the processor dashboard. Confirm the account is in test mode. Stripe test keys start with sk_test_ and pk_test_. Keys for production mode start with sk_live_ and pk_live_.
- Load the checkout page with the test publishable key.
- Enter a test card number from the processor list.
- Enter an expiry date after today. Use 12/34 if the page needs a value.
- Enter a 3-digit CVC. American Express uses 4 digits.
- Enter a postal code. Stripe accepts any value for 4242 4242 4242 4242.
- Submit the payment. Read the result in the dashboard or the API response.
Read the result
An approval returns a charge object with status succeeded. A decline returns a decline_code. Stripe returns card_declined for 4000 0000 0000 0002. The API response includes a request ID. Log that ID. The dashboard shows the same event.
Rules that prevent mistakes
- Do not enter a test card in a checkout in production mode. The processor rejects the number or flags the attempt.
- Do not use keys for production mode in a test environment. A key for production mode sends the request to the card networks.
- Do not treat a test card number as a card with a bank account. It has no account behind it.
Errors
A 402 error means the card was declined. Check the decline code. A 401 error means the API key is wrong or the mode is wrong. A test card with a key for production mode returns an error or a fraud flag. Test cards do not pass 3-D Secure unless the processor supplies a test flow.