#david-llop-_code
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/1332004649573679265
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- david-llop-_webhooks, 53 minutes ago, 6 messages
Hello there
That's correct -- for setup mode you would not include any line items.
ah okay I thought they were the same payload both cases but line items got ignored
thank you ๐ซก
Sure thing
$session = $stripe->checkout->sessions->create([
'line_items' => [[
'price_data' => [
'currency' => $order->amount()->currency(),
'product_data' => [
'name' => $order->orderDescription()
],
'unit_amount' => $order->amountAsInteger(),
],
'quantity' => 1,
]],
'mode' => $order->amountAsInteger() > 0 ? 'payment' : 'setup',
'success_url' => $order->urlSuccess(),
'cancel_url' => $order->urlFailure(),
'metadata' => [
'order_id' => $order->id(),
'amount' => $order->amountAsInteger(),
],
'customer_creation' => 'always',
'customer_email' => $order->email(),
'payment_intent_data' => [
'setup_future_usage' => 'off_session'
],
]);
This is my whole payload system. I guess payment_intent_data is also only required when there's money over the table, but the others can stay, right?
Correct
line_items gone, payment_intent_data gone, and mode can be forced to setup since I need this code separated into 2 methods, one for PI other for SI
nice ๐
May I ask a final question before closing this thread, to determine whether the webhook has an error, I use this code
public function hasError(): bool
{
return in_array($this->request->input('type'), [
'checkout.session.expired',
'checkout.session.async_payment_failed',
'charge.failed',
'charge.expired'
]);
}
Is this correct or I'm missing some of them? Extracted them from the documentation (a few weeks ago... ๐
). For now I only work with Payment Intent and Setup Intent
Yep, that encompasses the relevant Event types
Not really charge.expired
But the other 3
charge.expired is if you are using manual capture and then don't capture the Charge after it was successfully authorized.
So not really a charge failing or the Checkout not being successful in this case.