#Ankoro
1 messages · Page 1 of 1 (latest)
Unfortunately there isn't a way to directly set that metadata from the checkout session but you can set it up such that you can pass it on later via a webhook
If you set the metadata in the subscription_data hash, it will appear on the subscription that is created. Any invoices that are created for that subscription will have the subscription's metadata on the invoice line items that are related to the subscription
So if you set the metadata via subscription_data, you can wait to listen for an event like invoice.finalized or invoice.payment_failed and copy the metadata on the invoice to its payment intent
Oh ok, tanks so I can use "invoice.finalized" for a one time paiement and for subscriptions, by that I get metadata payment_intent in one time paiement and for sub, by subscription_data.
Thanks you !
Of course, glad I could help. How metadata gets passed around can be a bit weird
Also now that I think on this, it might be hard to guarantee that the metadata will actually be on the payment intent when you get the payment_intent.payment_failed event. As a backup, your code may want to just look up the invoice based on the payment intent's invoice field if it isn't there already
Ok thanks, I will try to do that !