#Sharvari96

1 messages ยท Page 1 of 1 (latest)

glossy rootBOT
old iris
#

Hi again ๐Ÿ‘‹ what's your follow-up question?

worthy flower
#

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

old iris
#

Ah, was hoping for more context than that. I'll need several minutes to go back and review what you're referring to.

worthy flower
#

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?

old iris
#

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.

worthy flower
#

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?

vernal ivy
#

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

worthy flower
#

Ok

vernal ivy
#

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

worthy flower
#

Ok

#

And can you review my success scenario?

#

given in one of the messages above

vernal ivy
#

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?

worthy flower
#

Ok, I will share the test mode payments

#

that are sucessful and a screen shot of the events recieved

#

give me 5 mins

vernal ivy
#

If you could send the IDs of the events instead of screenshots that will help me look in to this a bit better

worthy flower
#
  • "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?

vernal ivy
#

Just one of them should do, I can probably look up any other relevant ones from there

worthy flower
#

ok

#

evt_3NNcKRLbsWAvIKo91AqrQQYY - "payment_intent.created"

vernal ivy
#

And basically your question is which of the events should you listen to to know that they payment has actually succeeded?

worthy flower
#

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!

vernal ivy
#

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

glossy rootBOT
worthy flower
#

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?

jagged lily
#

If so, that is what being generated

worthy flower
#

Yes ok

#

Thanks

#

Much for the help!