#ezequielpato.
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- pato-subscription-data, 1 day ago, 27 messages
Hi, how can we help?
Hola. Tengo novedades de mi código.
Stripe webhook is running OK
I'm using Stripe CLI to test my local code
But now.. I don´t know what to do
Are you wanting to set up webhooks for a production server? Do you have a website that is going to be handling webhooks?
I'm coding right now the backend for webhooks.
I could finished the code for subscriptions and it is working well
Are you running into any issues? What can we help with?
roadrunner_stripe recommend me to use Stripe webhook to handle the information at the moment the subscription success. And after... for example when an user (inside my platform) tries to enter into a course (educative platform) and at that moment my code have to do a fetch to stripe to check the subscription status.
I supouse that i have to save some keys.. (subscriptio successfuly) like subscription id and customer id to check them later
Yeah, it might be a good idea to spin up a database for storing that info so you can access it without having to make a bunch of API calls through the internet
That's what I would do at least
Good, excellent. I have a dB right now
I could save those values. subscription id and customer id and subscription status on my data base
And at the moment that an user try to enter a course. Do a fetch ? and compare the sub status ?
but using some webhook method or just a simple fetch ?
At that moment i feel confused...
What are you trying to do with the subscription? Are you just wanting to provision access to the course at this point?
Yes
When a user try to enter a course. If the user subscription is ok at that moment. The user could see the material of the course.
You would just make sure to store the status of the subscription in your database (by listening to subscription.updated) so that you can look it up each time they access the course
But If the user subscription is not ok at that moment. The user just see the buy course message.
Would the query be to the database?
Stripe webhook just update my database
Yup! That would be the fastest way, otherwise you could make a retrive call to get the Subscription status directly from Stripe
Yeah, you can make sure that your database is up-to-date in order to get the status from your database as well
Ok i understand
So the way is
User buy a course doing a subscription to stripe.
At that moment, Stripe, using webhook, update my database.
Saving the values sub id, customer id, sub status
So when a user enter to a course i just need to check to my db
That sounds right, yup
Yup! Time to read the docs for whichever database and ORM (if applicable) you're using
Ok one more question
I only have the users saved in my database, not in Stripe.
When a user makes a successful subscription
Stripe returns me a customer id associated with that subscription
I need to take that value and save it to my database and associate this to my user
Yup!
It might be worth associating the customer and their subscription to your user as well. Will make it easier to lookup later on
I have the following doubt. if the same user (in my db) make a new subscription to another course with the same email.
the customer id will be the same? but with different subscription id ?
(the courses are in my db too) In stripe i don't have users or products registered.
Yup, you would have a Customer object that's associated with multiple Subscriptions
Okok is good to know it
How should I manage events when a user cancels their subscription or changes their payment method?
You would just need to listen for events related to those actions like customer.subscription.deleted --> https://stripe.com/docs/api/events/types#event_types-customer.subscription.deleted and payment_method.updated --> https://stripe.com/docs/api/events/types#event_types-payment_method.updated
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.