#Anne
1 messages · Page 1 of 1 (latest)
I won't be able to reopen the thread but happy to continue here.
"You're getting the data you need from the Checkout Retrieve with expand: ['invoice.charge'] right?"
I am not sending a checkout retrieve request. I send a checkout create request. Then listen for the following webhooks (since we use the Stripe pre-built checkout page): Checkout session, Charge, Invoice, Subscription, Dispute. When the Checkout session webhook returns an object withcheckout.session.completed', the payment_intent key is null for subscription purchases.
"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.
I believe there is no checkout session id in the charge api response. I will double check.
What do you mean by 'charge api response'? On subscription mode payments, you'd look at the invoice.
When a user purchases a subscription from our company, our webhook receives a response from the Stripe Charge Api.
Are you referring to charge.succeeded event?
Oh, my mistake. I assumed that was coming from the Charge API.
yes the charge.succeeded event.
On this event, you're not seeing "payment_intent"? Can you share the event id where this is the case so I can further look?
Let me rephrase my original question (now that events are more clear to me).
Does an event containing charge.succeeded also contain the checkout session id?
This was not the issue. I am seeing payment_intent on the charge.succeeded event
Mostly no
a Charge has a link to the Invoice in_123 that created it. And an Invoice has a link to the Subscription sub_123 that created it
there isn't a direct link from a Charge to Checkout
Is there an indirect way to link to the Checkout id?
the link I explained
For one-time payments you do Charge -> PaymentIntent and then you use https://stripe.com/docs/api/checkout/sessions/list + payment_intent: 'pi_123'
For recurring payments you do Charge -> Invoice -> Subscription and then you use https://stripe.com/docs/api/checkout/sessions/list + subscription: 'sub_123'
a Charge has a link to the Invoice in_123 that created it. And an Invoice has a link to the Subscription sub_123 that created it
There is no mention of checkout session in this link
Okay, I think the link you typed above helps.
What I would do personally is set custom metadata in subscription_data or payment_intent_data so that the metadata is on those objects and I don't need to go link back to Checkout
I don't think I can use metadata because our company uses the Stripe pre-built checkout page.
we're just listening to webhook responses. Not sending any Stripe requests (aside from the checkout session request)
Thank you for your help!
you can use metadata, that's what I was trying to explain
Can you show me an example how to use meta data? Maybe I am misunderstanding its use.
What' blocking you? Your code creates a Checkout Session via the API right? So you can set the metadata you want via
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
If I understand those links correctly, you can add metadata to the subscription object or payment intent object when creating a checkout session. I didn't know that was possible!
yes exactly!
Stripe won't let me set the metadata for payment_intent in subscription mode 😦
(Which confuses me because a payment_intent value is returned in the charge.succeeded event.)
Hopefully, I can connect the data the way our company needs using the subscription metadata.
For subscription mode, you can set the metadata on https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata. Let me test to confirm
that's correct that's why I explained there are the two
you can't control the PaymentIntent for a Subscription, since there's one per Invoice and there will be more Invoices in the future
okay, so I will set the metadata on the subscription_data in the checkout session. And then do the indirect way (using expand to send fewer requests) when our code catches an event with charge.succeeded:
...a Charge has a link to the Invoice in_123 that created it. And an Invoice has a link to the Subscription sub_123 that created it
I need to take a break now. Thank you for all your help.