#ThePinkGuy
1 messages ยท Page 1 of 1 (latest)
Hello ๐
A better option would be rely on webhooks
You can build an endpoint to receive updates whenever the customer changes anything about their plan (and then you can write some logic that updates your database accordingly)
https://stripe.com/docs/webhooks
https://stripe.com/docs/billing/subscriptions/webhooks
wait some time, I am using all of my brain to understand the docs
NP! take your time
so , what are the events that I need to listen to if I am in the following situation:
1 - I offer a 30 days trial for all 3 plans
2 - I update the database every time that the payment succeeds or fails
3 - I update the database every time that the trial period ends
now here is what I think I will be listening to :
1 - customer.created -> this one triggers once the customer subscribes to the free trial right?
2 - invoice.paid -> I will get the name of the plan that the customer pays , and update the database
3 - invoice.payment_failed -> I will get the id of the customer and remove the subscription
4 - customer.subscription.deleted -> because why not
I won't be listening to the following
1 - invoice.subscription.updated -> because if the customer changes subscription , then it triggers an invoice.paid , an event that I am already listening to
Hello! I'm taking over and catching up...
humm okie
That list of Events makes sense to me. One thing I want to point out is that customer.created fires whenever a Customer is created, not just Customers associated with a Subscription.
okye, in my case though the only thing that I am selling is the subscription , so that's the only time that it gets triggered right?
If that's how you built your integration, yes. But in the future you may create Customers for other reasons as well. Just want to make sure you're aware and take that into account. ๐
and one last thing, how do I create a subscription with 3 different tiers that the customer can update (on the individual customer page hosted on stripe)? I tried creating a product with 3 prices but it does not work
yeah sure ๐
You mean in the Customer Portal? You should be able to create three Prices and have them show up as long as you configure the Portal to allow that to happen.
If you go to https://dashboard.stripe.com/test/settings/billing/portal (that's a test mode link) and expand the Subscriptions section are the Products and Prices you want people to switch between listed under the Eligible products section?
so right now I only have this product
it has 2 prices as you can see
but I cannot add the second pricing because this pops up
Yep. It doesn't make sense to offer two Prices for the same interval; people would always choose the cheaper one.
Can you tell me more about your use case?
well there is going to be the basic plan , and other 2 plans
the basic plan will have a call limit of 1000 req/monh , and so on
It sounds like you want to use tiered pricing for that: https://stripe.com/docs/products-prices/pricing-models#tiered-pricing
Tiered pricing will automatically adjust the amount based on usage.
so I think I fixed it
I added another product and now it works.
so this is how the plans will work :
A - access to feature A
B - access to feature A and B
C - access to all features
this is the right way to do it right?
the customer can only have plan A,B or C , not 2 at the same time
That sounds good to me. Make sure you test all the options in test mode to make sure there are no surprises though! ๐
Okie
Btw, lets say that I use a service worker instead of the webhook, what is the best and fastest way to get the subscription plans of 10k customers through the api?
Not sure how a service worker would be involved, but you would need to fetch them from the API. I recommend you use the auto-pagination feature in our official libraries: https://stripe.com/docs/api/pagination/auto
You can list Customers: https://stripe.com/docs/api/customers/list