#chloe_code
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1303684748727816242
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! it depends what you want really. A Subscription creates an Invoice every month, an Invoice has a PaymentIntent.
You can go backward from a PaymentIntent by https://docs.stripe.com/api/payment_intents/object#payment_intent_object-invoice to back "up" that tree.
For a payment (either one time purchase or subscription). The subscription is recurring monthly or annual. All i need to know is that when a payment happens, a postgres table «order» is created for that customer. But for a subscription i need to keep track if subscription is valid or not, to see if customer have access to a given product for example.
If i store subscription_id and/or paymentintent id on «order» table, is that enough to check it subscription is valid for a customer based on order table?
So when i fetch a order for a customer, i can get subscription by id with stripe api, and then see if subscription has ended or not, and grant or deny access to a product
technically yes since you can retrieve everything from the API anyway and reconcile that way once you have any of those IDs.
In general I think the normal approach is to have a Subscriptions table with something like an "active_until" date, and you bump that date when you detect a successful invoice payment
I suppose i can listen for subscription payment success or renewal success webhook? And then if successful, bump «active_until» date to first day next month for example? Does all subscriptions create an invoice? Even if subscription is payed with credit card? I can support both invoice and credit card. So i need to listen in webhook for both successful invoice payment for a subscription and successful subscription payment credit card?
Does all subscriptions create an invoice? Even if subscription is payed with credit card?
yes and yes
I see in subscription its a «invoice.paid» webhook. So this is triggered for both successful payment with both credit card and if a invoice is sent and its payed?
Or do i need to listen for «payment_intent.succeeded» webhook event aswell? I see that is a event on subscription aswell
Yes invoice.paid is triggered whenever a invoice is considered 'paid' – that counts as scenarios where there's no payment due, too: