#keerthie-paymentintent-charge

1 messages · Page 1 of 1 (latest)

hexed stirrupBOT
dusky sluice
#

HI 👋

You can't add a custom detail to the event but can you explain what you are after here?

sinful cape
#

i want to save the events with a userID(custom user id say from AWS) so that i can tract the events across the users

dusky sluice
#

What events are you referring to?

sinful cape
#

payment_intent, charge, checkout

#

also if you can advise whether we need to have a track off all these events or just any one will be fine?

dusky sluice
#

Those are objects, what events are you listening to?

sinful cape
#

charge.failed, charge.succeeded, payment_intent.canceled, payment_intent.created, payment_intent.payment_failed, payment_intent.succeeded, checkout.session.completed

dusky sluice
#

And what is it you are actually trying to keep track of?

#

Just when a payment succeeds/fails?

sinful cape
#

yeah!

dusky sluice
#

Do you need the line items associated with the payment?

#

From the Checkout Session?

sinful cape
#

yes, i would be needing that

dusky sluice
#

Okay so the best bet for the UserID is to add it to the Checkout Session as metadata

#

You would also want to add it to the Payment Intent by including it in the payment_intent_data.metadata parameter when creating the Checkout Session

sinful cape
#

thats helps thanks. another doubt, just having the track for payment_intent object and checkout object will it give the result whether the payment is success or not?

dusky sluice
hexed stirrupBOT
dusky sluice
#

If the payment fails it will fall back to requires_payment_method. A payment_intent.payment_failed event will also fire

sinful cape
#

yeah! but in my case i am storing the receipt url for future use so without charge object i am unable to get the receipt_url, due to this i am tracking all the 3 objects; payment_intent, charge, checkout

eager arch
#

keerthie-paymentintent-charge

#

You can ingest all this information server-side once the Checkout Session completes successfully. Retrieve the underlying PaymentIntent, look at the Charge in latest_charge. You can use the Expand feature https://stripe.com/docs/expand to access all that information in one call

sinful cape
#

Great Thanks.

#

is there a way to get the receipt_url from checkout.session object?

eager arch
#

The receipt URL is on the Charge. A Charge is associated with the PaymentIntent. The Checkout Session creates that PaymentIntent. The way you get to the receipt URL is by navigating the connection between those objects
Session -> payment_intent: 'pi_123' => PaymentIntent -> latest_charge: 'ch_123' => Charge => receipt_url
and instead of having to make many API Requests to get there, you can use the Expand feature I mentioned above https://stripe.com/docs/expand to retrieve all those objects at once