From the Stripe dashboard, I create some Products (standard pricing, one-time purchase), and then I create a Pricing Table that includes those products.
I then setup a webhook from Stripe to send the charge.succeeded event, the payment_intent.succeeded event and the checkout.session.completed event to my back end server.
When a product from the pricing table is purchased, I successfully receive the above webhook events.
But looking thru these events, there is no product information transmitted with any of the above events, so I do not know what product was purchased.
Each of the above event objects includes id's for other objects, so using the Stripe API I can retreive these other objects (like customer object), but I am still unable to find any product information in these other objects as well.
So I can retreive the payment_intent object, the charge object, the checkout_session object, and the customer object, but I am unable to figure out how to get to the product that was actually purchased.
NOTE: It looks like the checkout_session object id is the one I need (products purchased are called 'line items'), but for some reason, when I retrieve a Checkout Session object using 'expand line_items', it will not return any line items... I just get the exact same normal checkout session object as if I did not use expand line_items. According to the Stripe API docs, this is supposed to work, but it is not working for me. Per the Stripe API docs, this should work: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items
Code examples for PHP ... all of these calls below simply return the normal Checkout Session object with no line items:
\Stripe\Stripe::setApiKey('stripe_api_secret_key');
$get_line_items = \Stripe\Checkout\Session::retrieve( 'cs_checkout_session_object_id', [ 'expand' => ['line_items'] ] );
$get_line_items = \Stripe\Checkout\Session::retrieve( 'cs_checkout_session_object_id', [ 'expand' => ['data.line_items'] ] );
$get_line_items = \Stripe\Checkout\Session::retrieve( 'cs_checkout_session_object_id', [ 'expand' => ['line_items.data'] ] );