#silvaleal_api

1 messages ¡ Page 1 of 1 (latest)

junior trenchBOT
#

👋 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/1343656430737166437

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

rigid spade
#

My function:

public function payment()
    {
        foreach (Cart::get() as $item) {
            $product = Product::find($item->product_id);
            $items[] = [
                'price_data' => [
                    'currency' => 'brl',
                    'product_data' => [
                        'name' => $product->name,
                    ],
                    'unit_amount' => $product->price * 100,
                ],
                'quantity' => 1,
            ];
        }
        $stripe = new \Stripe\StripeClient(config('services.stripe.secret'));

        $checkout_session = $stripe->checkout->sessions->create([
            'line_items' => [
                [
                    'price_data' => [
                    'currency' => 'brl',
                    'product_data' => [
                        'name' => "1",
                    ],
                    'unit_amount' => 2 * 100,
                ],
                    'quantity' => 2,
                ],
            ],
            'metadata' => ['test'=>1],
            'mode' => 'payment',
            'success_url' => route('payment.success'),
            'cancel_url' => route('payment.cancel'),
        ]);
        return redirect()->away($checkout_session->url);
    }
hollow fable
rigid spade
#

This is my first contact with Stripe, sorry for any stupid mistakes

#

@hollow fable

hollow fable
#

Can you paste the request ID in here? The one starting with req_?

rigid spade
#

yes

#

req_v6ZMS68PECqcJ8

hollow fable
#

Thanks, looking...

rigid spade
hollow fable
#

IDs starting with pi_ are for Payment Intents. You're probably listening for a payment_intent.* Event type, like payment_intent.succeeded. All of those are going to have a Payment Intent inside.

#

Checkout Sessions, on the other hand, start with cs_ and there are checkout.session.* Events you can listen for which contain the Checkout Session, like checkout.session.completed.

rigid spade
#

humm, thx

hollow fable
#

It sounds like you probably want to switch to listening for checkout.session.completed.

rigid spade
#

I'm only picking up when payment is created/successful

#

I'll try it, thanks for the support, it was very quick

hollow fable
#

Happy to help!