#keerthie-paymentintent-charge
1 messages · Page 1 of 1 (latest)
HI 👋
You can't add a custom detail to the event but can you explain what you are after here?
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
What events are you referring to?
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?
Those are objects, what events are you listening to?
charge.failed, charge.succeeded, payment_intent.canceled, payment_intent.created, payment_intent.payment_failed, payment_intent.succeeded, checkout.session.completed
And what is it you are actually trying to keep track of?
Just when a payment succeeds/fails?
yeah!
yes, i would be needing that
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
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?
The payment intent will have a status field that will indicate what state it is in: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status
If the payment fails it will fall back to requires_payment_method. A payment_intent.payment_failed event will also fire
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
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
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