#Vince
1 messages ยท Page 1 of 1 (latest)
sry i think i need more context ๐
yeah. are you the one who helped me earlier?
what I want is that I wan to save the record to a table (mysql) and I want 3 data (product price, service fee, and the vat). Some webhooks got identical properties. What do you recommend?
Ah yeah we were chatting earlier ๐
i can add it in the metadata property but i need to calculate it.
You want to listen for checkout.session.completed
nice. this is what I am currently using.
See: https://stripe.com/docs/payments/checkout/fulfill-orders which talks about fulfillment
But yeah you can basically retrieve whatever you need based on checkout.session.completed
but i want to make sure that the customer's transaction is completed before I insert it in my own table.
Yep checkout.session.completed will indicate it has been completed
i thought i will use the charge.succeeded
Yeah I mean you can
Either work, just depends on what info you want.
But you can get to the Charge from checkout.session.completed, you would just retrieve the Checkout Session and expand the payment_intent.latest_charge
but in the checkout.session.completed object. what I only see is the vat and the total amount. How can I retrieve the products I bought?
I mean I can do a calculation in the backend. but does stripe have it?
Yep to see that stuff you retrieve the Checkout Session using https://stripe.com/docs/api/checkout/sessions/retrieve and expand the line_items as those aren't returned in the Webhook/by default (see: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items)
oh okay. I see. thank you. seems i need to do more reading ๐
I dont know if I did it correctly but I am using it in this way
$line_items = \Stripe\Checkout\Session::retrieve('cs_test_b1bVKFxPQN7iOYRw1bHcgHi10ULHKjSh4KxcMW8t1Ni7NGuSmWRshUfqtl');
return $line_items;
Take a read through https://stripe.com/docs/expand
That explains how to use expansion
You specifically want: $checkoutSession = \Stripe\Checkout\Session::retrieve([ 'id' => 'cs_test_123', 'expand' => ['line_items'], ]);
yeah definitely this. thank you โค๏ธ