Test Credit Card Number Generation for Payment Testing
Payment gateways provide specific test card numbers for development and testing. Using the correct test numbers ensures your checkout flow works without charging real cards.
Key Takeaways
- Use any future expiration date, any 3-digit CVC (or 4-digit for Amex), and any postal code.
- PayPal provides sandbox buyer accounts with pre-configured balances.
- All valid card numbers pass the Luhn check โ a checksum algorithm that catches typos:
- Never use real card numbers in test environments** โ even your own
Ratio Calculator
Simplify, scale, and find equivalent ratios
Stripe Test Card Numbers
| Card Number | Brand | Behavior |
|---|---|---|
| 4242 4242 4242 4242 | Visa | Success |
| 5555 5555 5555 4444 | Mastercard | Success |
| 3782 822463 10005 | Amex | Success |
| 4000 0000 0000 0002 | Visa | Decline (generic) |
| 4000 0000 0000 9995 | Visa | Decline (insufficient funds) |
| 4000 0025 0000 3155 | Visa | Requires 3D Secure |
Use any future expiration date, any 3-digit CVC (or 4-digit for Amex), and any postal code.
PayPal Sandbox
PayPal provides sandbox buyer accounts with pre-configured balances. Log into the PayPal Developer Dashboard to create sandbox accounts with specific currencies and limits.
The Luhn Algorithm
All valid card numbers pass the Luhn check โ a checksum algorithm that catches typos:
- Starting from the rightmost digit, double every second digit
- If doubling produces a number > 9, subtract 9
- Sum all digits
- If the total is divisible by 10, the number is valid
Test card generators produce Luhn-valid numbers that pass frontend validation but are recognized as test numbers by the payment gateway.
Card Brand Detection
| Brand | Starts With | Length |
|---|---|---|
| Visa | 4 | 16 |
| Mastercard | 51-55, 2221-2720 | 16 |
| Amex | 34, 37 | 15 |
| Discover | 6011, 65 | 16 |
Important Warnings
- Never use real card numbers in test environments โ even your own
- Test mode API keys process test cards only; live keys process real charges
- Log test transactions separately from production
- Always test both success and failure paths โ declined cards, expired cards, and 3D Secure challenges