#Anne

1 messages · Page 1 of 1 (latest)

maiden peakBOT
somber arrow
#

I won't be able to reopen the thread but happy to continue here.

verbal crescent
#

"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 with checkout.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.

somber arrow
#

What do you mean by 'charge api response'? On subscription mode payments, you'd look at the invoice.

verbal crescent
#

When a user purchases a subscription from our company, our webhook receives a response from the Stripe Charge Api.

somber arrow
#

Are you referring to charge.succeeded event?

verbal crescent
#

Oh, my mistake. I assumed that was coming from the Charge API.

#

yes the charge.succeeded event.

somber arrow
#

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?

verbal crescent
#

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?

verbal crescent
scenic marsh
#

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

verbal crescent
#

Is there an indirect way to link to the Checkout id?

scenic marsh
#

the link I explained

verbal crescent
#

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.

scenic marsh
#

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

verbal crescent
#

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!

scenic marsh
#

you can use metadata, that's what I was trying to explain

verbal crescent
#

Can you show me an example how to use meta data? Maybe I am misunderstanding its use.

scenic marsh
verbal crescent
#

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!

scenic marsh
#

yes exactly!

verbal crescent
#

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.

somber arrow
scenic marsh
#

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

verbal crescent
#

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.