#Anne
1 messages · Page 1 of 1 (latest)
Hi, can you add more details on what you're really trying to do? Metadatas are not copied over to other objects. So if you're using Checkout and have passed the metadata on the checkout session, https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata you'd only see it here. Can you share what you mean with 'so I am not able to send metadata.'?
Hi. My goal is to tie a checkout session object to a charge object. My theory was that I might be able to do that with metadata. But if metadata is not copied over to other objects, than I need another solution.
I see, typing how you can do this..
Ty!
I was able to test this on my end, and it appears that although you cannot directly attain the charge object from the Checkout event, you can retrieve the Payment Intent from the Checkout session. You can use the expand feature, https://stripe.com/docs/expand when retrieving the Payment Intent: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-latest_charge
You can also directly retrieve the Checkout session object, https://stripe.com/docs/api/checkout/sessions/object and expanding its payment_intent.latest_charge
Thank you. Will this work for a subscription?
Yes!
Let me rephrase that, can I retrieve the Payment Intent from the Checkout session using the expand feature when the checkout session object originally had checkoutSessionObject.mode.subscription
I will test...
I see, no it's not going to work as that is for 'payment' mode only
With subscription mode Checkout sessions, you'd expand the invoice: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-invoice
Just confirmed, it would be expand: ['invoice.charge']
I don't believe that will work for us. We are trying to save data from the Charge Api response when a subscription is purchased by the user. In particular, we need to save the billing_address, charge_id, and refund details (if there is a refund involved.) And we need to tie this to the checkout session because we save the checkout session id in our database with a user id when the checkout api responds.
You're getting the data you need from the Checkout Retrieve with expand: ['invoice.charge'] right? So when you get the event that charge is succeeded, you can retrieve this session and see this details you're looking for to save the data.