#pablo-escobar-paris_api

1 messages ¡ Page 1 of 1 (latest)

rancid cometBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1275149129470836819

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

visual hearth
#

Hi, so i am using PHP library to implement stripe checkout. I have the following code which is creating the stripe hosted checkout page:


        $session = StripeSession::create([
            'customer_email' => auth()->user()->email,
            'line_items' => [
                [
                    'price_data' => [
                        'currency' => 'USD',
                        'product_data' => [
                            'name' => $payable->title,
                            'description' => $payable->description,
                            'images' => [
                                $content->thumbnail_url,
                            ],
                        ],
                        'unit_amount' => $payable->price,
                    ],
                    'quantity' => 1,
                ],
            ],
            'mode' => 'payment',
            'metadata' => [
                'order_number' => $order->order_number,
            ],
            'success_url' => route('purchase.success'),
            'cancel_url' => route('purchase.cancelled'),
        ]);

        return $session->url;

As you can see I am passing the order number through as Metadata.

#

But the metadata is missing from the charge.succeeded event

#

Metadata does show in the checkout.session.completed event but i need in the charge.succeeded so i can do order fulfillment on my application

late raven
#

You can't propgate the metadata down to the Charge object unless you explicitly update the Charge object. It stays on the Checkout Session object.

The closest thing you could do would be to use payment_intent_data.metadata (https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata) to propagate it to the Payment Intent and listen instead for the payment_intent.succeeded webhook event (https://docs.stripe.com/api/events/types#event_types-payment_intent.succeeded)

visual hearth
#

Do those events: checkout.session.completed or payment_intent.succeeded tell me if the payment was successful and complete? I can use them but need to be sure that payment was completed before any order processign

late raven
#

Yup! Both will tell you that a payment was completed, since Chekout will error on failed payment attempts and prompt the user to try again before ever firing either event

visual hearth
#

Thanks, and do i need to check any values in those events to check the status or is the event itself is confirmation that payment was completed?

late raven
#

The event itself is confirmation

visual hearth
#

Perfect thank you boss