#ultrawelfare_webhooks
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/1443142745983029320
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I could put the planId on metadata of the checkout session but the problem is that for the first checkout I receive invoice.paid before checkout.session.completed... So I won't have the metadata yet...
Hi! Sorry by plan are you referring to specific prices: https://docs.stripe.com/api/prices/create?
Yes.. ? By plan i'm referring to an entity of my application. A user of my application can create a Plan and price it accordingly (for ex; 15โฌ per month).
Then other users can subscribe to this plan.
so for example user A creates a plan of id = 1 (in my app).Then user B subscribes to it.
When I'm making the checkout session with mode="subscription" I need a way to annotate that this subscription is meant for plan id = 1.
The problem I face is when the user first subscribes;
I receive invoice.paid before checkout.session.completed. The docs mention that I should look out for invoice.paid to track active subscriptions. But invoice.paid doesn't have anything for me to correlate it to my planId so I can update my application database and provision access....
Is themetadata object on the checkout session also available in invoice.paid event? I guess it isn't since the invoice doesn't have anything to do with sessions so I won't be able to grab the planId.
Are you passing your plan as a metadata for the Checkout Session or are you referrencing one of the parameters available in the checkout.session.completed event?
I'm not yet, I'm just trying to understand how I should do it ๐
If I pass my planId on the Checkout Session, would I also receive them in my invoice.paid webhook event?
Ok so planId is your own internal reference correct?
Yes!
Got it!
Can I also check if there is a reason you can't wait for the checkout.session.completed event?
I can wait for it, but for subsequent charges which happen automatically there won't be such checkout.session.completed event.
There would only be invoice.paid (https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=stripe-hosted#provision-and-monitor)
In that case I won't know which planId the subscription refers to. A user can have subscriptions to multiple plans in my application. Whenever I'm receiving an invoice.paid I need to know for which planId on my application it is for...
Got it! Give me a moment.
So you can pass the planId as a metadata via subscription_data.metadata when you create the Checkout Session: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
This will be propagated to the invoice. So when you get the invoice.paid event you can refer to parent.subscription_details.metadata field to check for the planId
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
oh okay I'll try that and then I guess I can only pay attention to the invoice.paid events instead of checkout.session.completed.