#silvaleal_api
1 messages ¡ Page 1 of 1 (latest)
đ 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.
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);
}
Hello! I can't review all of that code. Can you give me the request ID where you're trying to fetch the metadata in question? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Can you paste the request ID in here? The one starting with req_?
Thanks, looking...
Okay, so you created a Checkout Session with your PHP code and set some metadata on the Checkout Session itself. You should be able to see that metadata if you retrieve that Checkout Session from the API: https://docs.stripe.com/api/checkout/sessions/retrieve
I'll try here, another question, when my webhook receives the JSON the id is different from the "default" url
Mine: pi_3Qw6tN4heTecM8Yg0IzW0H4n
The one from the docs: cs_test_a11YYufWQzNY63zpQ6QSNRQhkUpVph4WRmzW0zWJO2znZKdVujZ0N0S22u
Is this my ID the one I should use or am I looking at the wrong ID?
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.
humm, thx
It sounds like you probably want to switch to listening for checkout.session.completed.
I'm only picking up when payment is created/successful
I'll try it, thanks for the support, it was very quick
Happy to help!