#ultrawelfare_webhooks

1 messages ยท Page 1 of 1 (latest)

zenith pelicanBOT
#

๐Ÿ‘‹ 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.

summer cloak
#

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

eternal spear
summer cloak
#

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.

eternal spear
#

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?

summer cloak
#

If I pass my planId on the Checkout Session, would I also receive them in my invoice.paid webhook event?

eternal spear
#

Ok so planId is your own internal reference correct?

summer cloak
#

Yes!

eternal spear
#

Got it!

#

Can I also check if there is a reason you can't wait for the checkout.session.completed event?

summer cloak
#

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

eternal spear
#

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

zenith pelicanBOT
modest stone
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

summer cloak
#

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.