Reputation: 121
I would like to test invoice.payment_failed event with VCR
Pseudocode:
In step 1 Stripe returns error saying I want to add an invalid card. I used "4000000000000119" card number from https://stripe.com/docs/testing
Basically I want to create a scenario where the user had card that was once valid when they first purchased something/subscribed. But a year later it's no longer valid.
I don't want to mock the event data and store them in yml. I fetch event directly from Stripe and record it with VCR.
Upvotes: 12
Views: 3287
Reputation:
Answer is: 4000 0000 0000 0341 card number. Described in https://stripe.com/docs/testing
Posted on behalf of the question asker
Upvotes: 2
Reputation: 4288
On several levels here, you're not testing your invoice.payment_failed
code—you're testing your entire application, or even testing Stripe itself. This is not productive.
If you want to test that your webhook handler correctly handles a failed payment, that's the only thing you need or want to test. If Stripe (or a VCR facsimile of Stripe) is involved in the testing process, odds are very high that you have application design or testing design issues you need to address.
Upvotes: -4