Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
365 views
in Technique[技术] by (71.8m points)

payment gateway - Stripe - How to handle subscription with a free plan and no credit card required at sign up time

We started to implement Stripe on Redsmin (one of our project) and I think we may have missed something. Here is how it works:

  1. To use our product, the user must select a plan (free, s, m, xl, xxl...) then enter its login/password and is then good to go for a free 30 days trial. When the user submits the form, our server calls Stripe create_customer with the specified plan and no credit card (because we want to offer 30 days free with no credit card required) and we update the user model on our side with the returned customer_id and subscription_id.

  2. We set up a webhook to receive stripe events so after 30 days our webhook should receive a customer.subscription.updated event with a object.status == active. Am I right?

  3. However, since we did not specify an associated card for the user at sign up time, we should receive quickly after another customer.subscription.updated event with object.status == unpaid right? Then on our side we deactivate the user account and force it to go to our plan selection page.

  4. From then on the user is able to select either the free plan or one of our premium plan:

  5. #Scenario 1 If the user selects the free plan, we just reactivate its account on our side and do nothing else because we configured the free plan on stripe to cost 0$. Did we implemented the right process with our free plan? Are there better ways?

  6. #Scenario 2 If the user selects a premium plan, we redirect him to a credit card form, that will then be sent to Stripe, and we update the stripe customer account with the temporary card token. What should we do next ?:

    • Should we wait for stripe to send us an event? If so, what event? customer.subscription.updated? charge.succeeded? What will be the value of object.status then ?
    • Should we directly reactivate the user account on our side and wait for a confirmation from stripe? If so, what would be the event name and data we should wait for?

image

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In part 2 where you do this:

We set up a webhook to receive stripe events so after 30 days our webhook should receive a customer.subscription.updated event with a object.status == active am I right?

You might also consider implementing the customer.subscription.trial_will_end webhook, this webhook will be sent three days before the customers trial is going to end and will allow you to send the customer a notification to update their payment information.

This way if the user does decide to go and update their payment information, Stripe will be able to take payment as soon as the customers trial has ended and they will be able to continue using your service without interruption.

#Scenario 1 If the user select the free plan, we just reactivate its account on our side and do nothing else because we configured the free plan on stripe to cost 0$. Did we implemented the right process with our free plan? are there better ways?

As far as I know this is the best way of implementing free plans using Stripe, I would just probably make sure that customers weren't sent any invoices unless it was required. I doubt users would expect to receive an invoice for each billing period if they were using a free plan.

#Scenario 2 If the user select a premium plan, we redirect him to a credit card form, that will be then sent to Stripe, and we update the stripe customer account with the temporary card token. What should we do next?:

  • Should we wait for stripe to send us an event, if so, what event? customer.subscription.updated? charge.succeeded? What will be the value of object.status then?
  • Should we directly reactivate the user account on our side and wait for a confirmation from stripe? If so, what would be the event name and data we should wait for?

Once the user has selected a plan and updated their payment information I would activate their account straight away providing that the response to the subscription update from Stripe was successful.

As long as you have configured your subscription preferences from your Stripe dashboard you should be able to let Stripe handle what it will do if the payment fails. Just make sure you implement the customer.subscription.updated webhook as this will be the webhook that Stripe will send you if they mark a subscription as unpaid or cancelled allowing you to update your own records accordingly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...