#ezequielpato.

1 messages · Page 1 of 1 (latest)

loud ridgeBOT
#

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.

hollow thistle
#

Hi, how can we help?

valid spear
#

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

hollow thistle
#

Are you wanting to set up webhooks for a production server? Do you have a website that is going to be handling webhooks?

valid spear
#

I'm coding right now the backend for webhooks.

#

I could finished the code for subscriptions and it is working well

hollow thistle
#

Are you running into any issues? What can we help with?

valid spear
#

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

hollow thistle
#

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

valid spear
#

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...

hollow thistle
#

What are you trying to do with the subscription? Are you just wanting to provision access to the course at this point?

valid spear
#

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.

hollow thistle
#

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

valid spear
#

But If the user subscription is not ok at that moment. The user just see the buy course message.

valid spear
#

Stripe webhook just update my database

hollow thistle
#

Yup! That would be the fastest way, otherwise you could make a retrive call to get the Subscription status directly from Stripe

hollow thistle
valid spear
#

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

hollow thistle
#

That sounds right, yup

valid spear
#

is it correct ?

#

OkOk

#

I need to read how to do it.

hollow thistle
#

Yup! Time to read the docs for whichever database and ORM (if applicable) you're using

valid spear
#

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

hollow thistle
#

Yup!

#

It might be worth associating the customer and their subscription to your user as well. Will make it easier to lookup later on

valid spear
#

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.

hollow thistle
#

Yup, you would have a Customer object that's associated with multiple Subscriptions

valid spear
#

Okok is good to know it

#

How should I manage events when a user cancels their subscription or changes their payment method?

hollow thistle
#

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

loud ridgeBOT
valid spear