1
votes

I am going to use Stripe to do payment process. Based on the documentation I come up with the following thoughts and some doubts regarding the free payment option.

I decided to use the DotNet API and checkout.js in my application.

Here is my understanding,

  1. I can manually create a plan from Stripe dashboard
  2. In UI, I can make use of "checkout.stripe.com/v2/checkout.js" to fetch the card information and payment, once stripe succeeded in fetching the payment, automatically call the server with a token and EmailID
  3. In server side,

    3.1) Create the customer with stripe token (StripeCustomerService)

    3.2) Create subscription with customer id & plan Id (StripeSubscriptionService) => Expecting payment will automatically handle at this stage based on the plan I already created from Stripe dashboard.

  4. I can activate the feature from my side.

  5. Stripe will automatically send email to the customer in each payment date and will send webhooks events based on that(How the email template will look like?)

  6. I can listen to the webhooks to activate/deactivate feature.

  7. I selected following events(might be I'll be missed some other events)

For to De-activate

charge.refunded

charge.failed

charge.dispute.created

customer.subscription.deleted

invoice.payment_failed

For to Activate

charge.succeeded

invoice.payment_succeeded

Please correct me if my understanding is wrong (or) I have to consider something more.

Now I am confused about providing free plans.

Regarding free plan,

1) How can I do the free plan with stripe without taking the card info for the first time?

2) Do I have to use checkout.js at this stage?

3) What events I have to take care of free plans? Saw "customer.subscription.trial_will_end" event and document say, it occurs 3 days before expire, but what event will occur on the day the trial ends?

2

2 Answers

0
votes

Your understanding of the subscription and event flow is correct and this should work. You should make sure to test all of this in Test mode to confirm that it works end to end for you.

As for the free plan, this is definitely possible but it's something you would build on your end in that case. It's on you to know the plan selected is free and to skip the card details collection. You can create a subscription to that plan and it will just work and fire similar events every month for example. You'll get invoice.payment_succeeded and customer.subscription.updated. You won't get a charge.updated event since there would not be a charge.

As for the trial ending, Stripe will send customer.subscription.updated when the new billing cycle starts and the subscription becomes active.

0
votes

To subscribe a customer to a free plan, card info is not required as Stripe won't charge the customer since the amount is zero.

And about how to identify trial period expiry, the best way to do that would be to create a subscription with a 40 day trial period. You can set up a subscription with a base amount and then set up customer.subscription.updated webhook to notify you when the trial ends, to update your end.

To check for trial expiry in customer.subscription.updated, look for the plan ID in the webhook event object and compare the status property with the status value in the previous_attributes property to see if it has changed from trialing to active.