How do I retrieve metadata from webhook event payment_intent which was part of my checkout session submitted to stripe The response I get from the webhook doesn’t include the metadata i had used in my checkout session creation
Stripe webhook events include the associated object data under the data
attribute. You can consult the webhook event list to see what types of events you can listen to and what object will be returned under data
.
PS: Stripe has a Discord channel that’s a great resource for getting answers to questions like this.
There’s no occurences of the word metadata in the paymnet_intent.succeeded returned object I doubt that channel would be of use to me because the stripe api reference isn’t ruby-on-rails, all requests are shown being made with curl If I were to join discuss.stripe.org i’d just be told this wasn’t a stripe question
I found in the docs payment_intent_data.metadata but so far I haven’t been able to use it in checkouts_controller code without getting a syntax error The idea was that the metadata included in my Stripe::Checkout::Session post request to the Stripe api server would be available in the returned object of the webhook event I’m listening for, payment_intent.succeeded
This is the section in the webhook event list documentation for the event you’re listening to.
It’s showing that the data.object
of the payload would be a payment intent.
This payment intent documentation shows that metadata
is an attribute of that object.
When working with Stripe webhooks, the payload of the webhook event may not include all the details you need, including the metadata you set during the Checkout Session creation. To retrieve the metadata associated with a payment_intent
, you may need to fetch additional details from the Stripe API using the provided payment_intent
ID.