'Stripe - add an invalid card to customer in test mode?

I would like to test invoice.payment_failed event with VCR

Pseudocode:

  1. create a customer with invalid card
  2. create an invoice with invoice item (here the invoice gets automatically paid)
  3. fetch the invoice.payment_failed event with Stripe::Event

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.



Solution 1:[1]

Answer is: 4000 0000 0000 0341 card number. Described in https://stripe.com/docs/testing

Posted on behalf of the question asker

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1