How to start a subscription in stripe with delay?

最后都变了- 提交于 2020-04-10 08:14:12

问题


I have a number of users who are currently subscribers to a monthly subscription.

For business reason, I want to be able to

1) Charge the customer when he decides to subscribe to our plan

2) Let the subscription become effective a number of days after the purchase

Currently a charge is immediately attempted when a subscription is added to a customer in stripe.

I want to stick to the stripe subscription because a) I still want to have stripe to manage subscription for me in future dates, and b) I have written a lot of code for the subscription model.

Is it feasible at all to demarcate the charge/invoice and the subscription start date?


回答1:


You can control the time when the subscription actually starts (i.e. when Stripe will start billing the customer) by using the trial_end parameter in your subscription creation request. Simply set the value of the parameter to the timestamp of the exact time you wish Stripe to start automatically billing the customer.

If I understand your desired payment flow correctly, you'd want to do something like this when a customer signs up:

  1. Collect and tokenize the customer's payment information (using Elements or Checkout).

  2. Using the resulting token, create a customer object and save the resulting customer ID in your database.

  3. Create a one-off charge using the customer object for the first payment.

  4. Create a subscription using the customer object and the trial_end parameter set to the time you want Stripe to start automatically billing the customer.

See https://stripe.com/docs/subscriptions/trials for more information about using trial periods.



来源:https://stackoverflow.com/questions/44652329/how-to-start-a-subscription-in-stripe-with-delay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!