#lewibs_api

1 messages ยท Page 1 of 1 (latest)

misty plinthBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!

๐Ÿ”— 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/1212190956095283200

๐Ÿ“ Have more to share? You can add more detail below, including code, screenshots, videos, etc.

โฒ๏ธ 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. Thank you for your patience!

royal sierra
quaint chasmBOT
royal sierra
#

I have 6 different things that can be purchased, 2 items and 3 subscription types. all of that is running through the same webhook to update the db info.

soft sapphire
#

Just to make sure we're on the same page, you're using PaymentLinks to create Subscriptions?

royal sierra
#

is this a person? not sure what im talking to.

yes i am using payment links. The thing i can copy and paste in a link in my website

soft sapphire
#

Yep, this is a person ๐Ÿ™‚

royal sierra
#

sweet your name made me think you were a webhook hahaha

#

yes that is what I am using. Ill send a link as an example

#

the id is refferencing a document in my database

soft sapphire
#

Thanks! Not sure what you mean by "checkout.session.completed runs last"

#

If a customer pays with a link that includes client_reference_id, you should see the client_reference_id value in the checkout.session.completed event. I see it in event evt_1OoaWAF8kTOyZ6EUKuQXydG6

royal sierra
#

yep its in the checkout.session.completed,

but I do actions on subscription created and subscription deleted and subscription updated so its important I know who those events belong to.

I mean it runs last in those 4 events when the user subscribes:

here is the output

#

i logged the event type followed by the event

soft sapphire
#

Gotcha. As for "it runs last", we don't guarantee the order of event delivery so you may get the checkout.session.completed event first/in a different order

#

client_reference_id will not be included in the Subscription events. That said, you can also look at the subscription on the checkout.session.completed event and then make a follow up call to retrieve the Subscription

royal sierra
#

does checkout.session.completed run every time the subscription is updated (a month passes in my case)

#

i add "seats" and "scans" to the user in my data base based on those events

soft sapphire
#

No, it's only emitted when a customer who is on session completes a Checkout Session

royal sierra
#

hmm im still having a hard time seeing how this info solves my problem

soft sapphire
#

Just to clarify, is your goal to essentially include the client reference ID on the subscription somehow?

royal sierra
#

since when the customer.subscription.created runs, it needs to be able to reference a customer in my DB but it cant do that if i can only get that from the checkout.session.compleated

royal sierra
soft sapphire
#

If so, you can make a follow-up call to update the subscription and add this ID to the subscription metadata. You'll receive customer.subscription.updated on renewal, which should include the full subscription object

royal sierra
#

if i update the metadata will that trigger the subscription updated?

royal sierra
#

maybe there is a checkout session created, or an event which triggers when someone clicks on the link? somthing which will run before anything and include the ref?

soft sapphire
#

Zooming out a bit, I think what you likely want to do here is keep a mapping record in your database between your internal IDs and a Stripe Customer ID.

quaint chasmBOT
soft sapphire
#

When a customer of yours uses a PaymentLink to subscribe and completes payment, the checkout.session.completed event will include the ID you passed in client_reference_id, the brand-new Subscription ID, and a customer ID for the newly-created customer. Going forward, the subscription, invoice, and payment events you likely want to keep track of will include the Stripe customer ID