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?
Test payment failures To test the effects of payment failure on an active subscription, attach the 4000 0000 0000 0341 card as the customer's default payment method, but use a trial period to defer the attempt (a trial of a few seconds or minutes is sufficient).
Open the form you want to run a Stripe payment check for and go to its Settings. Click Payment Options and check Stripe if it's not checked already. Then put the Checkout Mode to Testmode, click Update, and test away. Don't forget to switch to Production when you need to start accepting actual payments.
There are three possible reasons why a credit card payment might fail: Payments declined by card issuers. Blocked payments. Invalid API calls.
Testing paymentsYou can issue cards and simulate purchases using your own Stripe integration in test mode. This allows you to test your integration before you go live without having to make real purchases. You can only use these cards for testing within your Stripe account and not for external purchases.
You have two scenarios when a charge can fail:
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:
https://stripe.com/docs/testing#cards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With