There are some test credit card numbers, e.g. Visa's 4111 1111 1111 1111, and when you test with these cards, it is always a successful transaction.
How do I test a declined transaction? E.g. if the card is valid but doesn't have enough money for the transaction?
63 Answers
You have two scenarios when a charge can fail:
- Charge directly a customer.
- Attach a card to a customer and then try to charge that customer.
Stripe's documentation provides two test cards for those situations:
4000 0000 0000 0002"Charge is declined with a card_declined code."4000 0000 0000 0341"Attaching this card to a Customer object succeeds, but attempts to charge the customer fail."
You can use the card number 4000 0000 0000 0002 or token "tok_chargeDeclined" to get a declined test charge:
As @Muistooshort and @phlip mention in the comments, the Stripe documentation give a list of test cards that will return various error messages.
Common errors would be:
4000 0000 0000 0002 Card declined (e.g. insufficient funds)
4000 0000 0000 0069 Card expired
4000 0000 0000 0127 Incorrect CVC
Card dates can be anything in the future (for valid dates) or in the past to test invalid dates.