Search code examples
stripe-paymentswebhooks

Stripe webhook how to get f.... product ID or NAME or something data which help me identify what exact user bought


In payment_intent.succeeded I got a lot useless data, BUT CAN NOT FIND JUST ID OF PRODUCT USER BUY. This is obviously what 90% devs need, why can't this be added instead of a bunch of unnecessary information ????????????


Solution

  • PaymentIntents weren't designed to work with Prices/Products, they are a "lower level" object intended to create a payment for an "amount".

    You are likely using Stripe Checkout for one time payments which does work with Products/Prices. Checkout generates a PaymentIntent under the hood to facilitate the payment. The Product or Price details won't be obtained from the payment_intent.succeeded event but rather, from the checkout.session.completed webhook event.

    When you receive that event, you need to retrieve the Checkout Session object and "expand" the line_items field to obtain all the line items passed to Checkout and the underlying Prices and Products by passing expand: ["line_items.data.price.product"]