#lewibs_api
1 messages ยท Page 1 of 1 (latest)
๐ 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!
this is the code i have so
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.
Just to make sure we're on the same page, you're using PaymentLinks to create Subscriptions?
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
Yep, this is a person ๐
So you have a PaymentLink. Do you mean you're using client_reference_id? https://docs.stripe.com/payment-links/url-parameters#streamline-reconciliation-with-a-url-parameter
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
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
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
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
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
No, it's only emitted when a customer who is on session completes a Checkout Session
hmm im still having a hard time seeing how this info solves my problem
Just to clarify, is your goal to essentially include the client reference ID on the subscription somehow?
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
that would be a solution. But its really just associate all events, with a user in my database
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
if i update the metadata will that trigger the subscription updated?
my concern with this approach is that if checkout.session.compleated runs last, then the customer.subscription.updated and customer.subscription.created which ran before it wont have access to that metadata yet and so they wont be able to associate to a user
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?
No, there's no other event emitted
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.
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