#Hemant-checkout-events
1 messages ยท Page 1 of 1 (latest)
Hi there ๐ ah, looks like you're creating Checkout Sessions in subscription mode, so they won't have payment intents attached to them. You'll likely want to listen to checkout.session.completed events, and then retrieve the subscription that was created from there.
I have requirement to create subscription or direct payment. So can i assume i will get subscription object in case of subscription and Payment object in case of a Payment.
So i should save subscription_id and payment_intent_id , in case of subscription and payment respectively, in my database to check for the completion. Then listening to "checkout.session.completed" should mark them completed.
You can check for the ID of the Payment Intent immediately after creating the Checkout Session (in payment mode).
But in subscription mode the Subscription is not created until the customer completes checkout, so those you won't be able to retrieve until the checkout session has been completed.
But before forwarding to Stripe payment page , in case of subscription, i should have something to match , if the subscription is created(completed) or not. Isn't it ?
Shall i track it with session_id , i can see that. something like "cs_test_a1oJirohsBCZjjOY062LciuoFDmdsGv0iW7gMqFEpKOtRHNXgprMpK74li"
Yeah there are a couple options. You can track the ID of the checkout session as you mentioned, or you could provide your own tracking identifies via the metadata on the checkout session:
https://stripe.com/docs/api/checkout/sessions/object?lang=python#checkout_session_object-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Cool , thanks for the help @daring sail . Let me try that with session id only and update you. I think this session_id will work for both scenarios.
Awesome, happy to help!
I need to step away soon, so I'm archiving this thread but if there is anything else that my teammates can assist with then please them know in #dev-help ๐
hey @elder moss I've re-opened this
Thanks @pearl marsh
Can you please assist me with this quick question. When a checkout session is created and a user is forwarded to Stripe payment page. If user does not complete the payment and close the browser. Will i get an event back in webhooks ? If yes (as failed or incomplete), how long will stripe wait to send me that event ?
from main:
Hemant โ Today at 11:15 AM
#946418159890600006 messageHi team, in continuation to the above thread, i have a quick question. When a checkout session is created and a user is forwarded to Stripe payment page. If user does not complete the payment and close the browser. Will i get an event back in webhooks ? If yes (as failed or incomplete), how long will stripe wait to send me that event ?
By default, no, you wouldn't get any event in that case
But you can explore our cart recovery feature to enable session expiry events that would allow you to contact the customer if they consent to email contact and end up abandoning the session:
https://stripe.com/docs/payments/checkout/abandoned-carts
thanks @pearl marsh . Let me think over it and design a payment flow for my application.
NP!