如何模拟 Stripe 订阅续订失败?

How do you simulate Stripe Subscription Renewal Failure?

我正在尝试测试不同的 Stripe 订阅失败。具体来说,如果在最初接受卡并且订阅处于活动状态时续订有效订阅,但续订付款被拒绝,或者客户在订阅期间删除卡,会发生什么情况。

我如何在 Stripe 上模拟这个?

为了测试失败的订阅付款,您可以这样做:

  1. Create the customersource 参数中使用有效卡片的卡片标记(例如 4242 4242 4242 4242)。

  2. Create the subscription来计划。由于第一次收费成功,订阅将成功创建。

  3. Update the customersource 参数中带有故障卡片的卡片标记(例如 4000 0000 0000 0341)。

  4. Update the subscription with the trial_end parameter set to a few seconds in the future and prorate 设置为 false。这实际上更改了订阅的下一个计费日期。

到达 trial_end 日期后,将开始新的计费周期并创建发票。大约一小时后,发票将关闭并尝试付款。然后会发生什么由你决定 subscription account settings.

要测试您的第二个场景,您只需将上面的第 3 步更改为 delete the card,而不是使用故障卡更新客户。