Testing cards that expire after subscription has started.

97 views
Skip to first unread message

Marc Rohloff

unread,
Jan 31, 2018, 8:26:44 AM1/31/18
to Stripe API Discussion
Hi all,

I am struggling with testing that webhooks are executed correctly when the credit card attached to as subscription expires (or becomes invalid for another reason).

Although there has been some discussion on this in this forum (though the last post I could find dates back to 2016) as well as in the Stripe documentation https://stripe.com/docs/subscriptions/testing#payment-failures

these are problematic for two reasons:

1) This solution is complex to execute, even as a developer. It is certainly not something that I can expect testers to do nor can it be done using production ready code as expected on a staging environment since it requires setting custom trial end times.

2) Secondly it requires at least a day every time a test is run. This doesn't allow for any reasonably fast development or test cycle or make it possible to test (or remember) a large number of scenarios.

Is there any other means of testing that I am missing. TIt seems that there must be a better way to do this.

--
Marc


Remi J.

unread,
Jan 31, 2018, 8:32:18 AM1/31/18
to api-d...@lists.stripe.com
Hey Marc,

At the moment, the solution outlined in this section of the documentation is still what we recommend. You're correct that this can't be done manually in the dashboard today. Instead, you can write a test or build a custom UI to let your testers do this manually.

You should not need to wait for a full day either to do this. You should create a customer with the card 4000 0000 0000 0341 and then create a subscription with a trial period of a few minutes. Simply pass `trial_end` [1] set to a timestamp a few minutes in the future. When you do that, the subscription is created successfully (because of the trial). It will then automatically renew a few minutes later. At that point, an invoice is created. This invoice would be charged automatically an hour or two later but you can speed things up by calling the Pay Invoice API [2] to trigger a payment failure faster in your tests.

We know this makes testing renewals and payment failures trickier than it should be though and it's something we're looking to improve in the future.

Best,
Remi


--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.

Marc Rohloff

unread,
Jan 31, 2018, 12:45:07 PM1/31/18
to Stripe API Discussion
Looking at the instructions it would seem that, if I could create a plan with a trial period of a few minutes, then that would simplify this process.

Marc
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Remi J.

unread,
Jan 31, 2018, 12:48:00 PM1/31/18
to api-d...@lists.stripe.com
Hey Marc,

We have deprecated trial periods on plans for a while already. Today, if you create a subscription using the `items` [1] hash, the trial period on the plan would be ignored. You need to explicitly pass the trial period when you create the subscription instead.

This means that even if we supported this in the dashboard for plans it would not solve the problem at hand. I guess we could support trial periods of a few minutes in the dashboard in Test mode but it would be confusing to users who expect this feature to also work in Live mode afterwards.

This scenario is something we recommend testing with code instead of manually in the dashboard because of this.

Best,
Remi


To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.
Reply all
Reply to author
Forward
0 new messages