#Sharvari96
1 messages ยท Page 1 of 1 (latest)
Hi again ๐ what's your follow-up question?
Hi ๐
I was able to do what was asked for the failure scenario and I am able to capture the error message successfully...
I wanted tips on - what do you suggest we track as a webapplication?
payment intent or session id?
also, I need tips on - managing the success scenario
can the same payment Intent have more than one session id?
or can the same session id have more than one payment Intent?
right now I am tracking session id - and the event "checkout.session.async_payment_failed"
using that to retreieve the rest of the data as suggested
For succes scenario:
should I use:
- "checkout.session.async_payment_succeeded" to confirm that payment was done but not confirmed
- "invoice.payment_succeeded" to confirm the payment finally.
sorry for being too verbose
Ah, was hoping for more context than that. I'll need several minutes to go back and review what you're referring to.
Oh ok. Let me summarize - I am trying to configure and build webhooks to manage payment success failure etc...
I am using a checkout session url for the payment by the user these are the events and logic I am using upon the suggestion by a team member here
if event.type == "checkout.session.async_payment_failed":
session_id = event.data.object["id"]
session_obj = stripe.checkout.Session.retrieve(session_id)
session_obj = session_obj.to_dict()
payment_intent = session_obj["payment_intent"]
payment_intent = stripe.PaymentIntent.retrieve(payment_intent)
error = payment_intent["last_payment_error"]
# find session id
session = await core_service.read_one(
Collections.SESSIONS, {"session_id": session_id}
)
if session:
session_obj = await core_service.update_one(
Collections.SESSIONS,
data_filter={"session_id": session_id},
update={
"$set": {
"status": "checkout.session.async_payment_failed",
"error": error.to_dict(),
}
},
)
# get session_id, retreieve paymentIntent, retreieve paymentIntent and access last_payment_error
I have followups on this.
Now do u have context?
can I ask my questions?
I'm not sure of context, but please go ahead and ask your questions (you don't need to ask if you can ask questions in the future, please just ask them) and I will ask for clarifying context as needed.
ha ha ok
we u see, we are tracking session id in out webapp - is that the right thing to track?
or should we be tracking payment Intent instead?
You can track either, they will both go in to their successful state at the same time. The PaymentIntent is a bit more directly tied to the payment but the Checkout Session has a bit more info on what was actually purchased. You can always look one up by the other's ID so it is more a matter of which has data that you will need more often
Ok
can the same payment Intent have more than one session id?
or can the same session id have more than one payment Intent?
It is always a 1:1 ratio when Checkout is in payment mode
For succes scenario:
should I use:
- "checkout.session.async_payment_succeeded" to confirm that payment was done but not confirmed
- "invoice.payment_succeeded" to confirm the payment finally.
I think that async_payment_succeeded will only happen after the intent is fully confirmed. Are you getting this event when the intent requires another confirmation?
Do you have any successful test mode payments from testing this flow?
Ok, I will share the test mode payments
that are sucessful and a screen shot of the events recieved
give me 5 mins
If you could send the IDs of the events instead of screenshots that will help me look in to this a bit better
- "payment_intent.created"
- "financial_connections.account.created"
- "payment_intent.processing"
- "checkout.session.completed"
- "charge.pending"
- "charge.updated"
- "balance.available"
- "mandate.updated"
- "payment_intent.succeeded"
- "charge.succeeded"
- "checkout.session.async_payment_succeeded"
- "invoice.created"
- "invoice.finalized"
- "invoice.sent"
- "invoice.paid"
- "invoice.payment_succeeded"
This is the sequence of events.
do u need the event id of all of them?
Just one of them should do, I can probably look up any other relevant ones from there
And basically your question is which of the events should you listen to to know that they payment has actually succeeded?
yes
and which event to listen when the transaction is successfuly before the banks process it
to tell the user that - ur transaction is successfull, confirmation is pending. - and then finally its is confirmed!
You can listen to either checkout.session.completed or payment_intent.processing for when the payment intent initially goes in to that pending state
and then either checkout.session.async_payment_succeeded or payment_intent.succeeded for the payment fully succeeding
Ok
What are these invoice that get triggered?
In this flow?
I'm doing a checkout session url
Is it related to order success email?
Hello ๐
Have you enabled Post Payment Invoices on Checkout?
https://stripe.com/docs/payments/checkout/post-payment-invoices
If so, that is what being generated