#Gankerino - Checkout Session items
1 messages · Page 1 of 1 (latest)
Hello, good question. You can set the data on the subscription itself and copy it over to the payment intent with an API call later if you want, but unfortunately you are right that you can't directly set this metadata on the payment intent from the checkout session
That being said, the typical recommended way to get a checkout session's items is by retrieving the checkout session itself
So here, you will likely want to listen to some webhook event for either the checkout session or subscription, and use that to make an API call to update the payment intent's description
Hey thanks for the quick response. The webhook stuff sounds good. But how would I get my data like the description I want to set from the payment_intent.created event?
I dont know by looking at the API description how to get the back-ref to a subscription/session/line-items from just the payment intent?
I dont see any field that might help me on the payment intent object
I think it would be hard to go from payment intent to checkout session, but the payment intent would have a subscription property that has the ID of the subscription that it is related to
So you can look up the subscription and check out its line items
Or, you can set the metadata on the subscription via Checkout as you do for payment intents, then when you get the payment intent events, directly copy the metadata from the subscription to the intent
Are you sure about that? I cant seem to find that property
Wait a moment, I misremembered slightly. Payment intents have an invoice property, the invoice will be linked to the subscription
Yep, just caught myself, apologies for the confusion
Ah ok thanks
A yeah I see, great I try that!
Also why is it that one time payments do not create a invoice if created with the checkout session? This would completely solve my issue and be less hacky. Is there a good way to overcome this?
You can't create Invoices for one-time payments with Checkout unfortunately
That being said, you can create Invoices for one time payments and use their hosted invoice page as a Checkout Session if you want
Also, is there a reason you aren't using a Checkout related event here? That could also give you a consistent event to look at for both?
Hmm I wanted to use the checkout page for both since it looks quite nice
What do you mean with checkout related event?
There is a checkout.session.completed event that will trigger when the user makes a payment with Checkout
So this would happen for each of these one-time payments or for the first payment on these subscriptions
And you can get data related to the session, subscription, payment intent, etc there and set whatever data you want from there
Ah ok. Yes I am already handling the checkout.session.completed event to do my internal updates. You are right I could just update the payment intent there with the metadata from the session.