#kiranovatheofficial
1 messages · Page 1 of 1 (latest)
Hi there!
Hello 🙂
So you want to automatically send an payment receipt by email when using the Checkout Session?
Exactly!
Did you enable that setting in your dahsboard? https://dashboard.stripe.com/settings/emails
Oh! Let me see
Also note that we don't send emails in test mode, onlyl in live mode.
Oh ok yes I get it
So if this option is enabled, the person that pay and succeed on the checkout session, got emailed with the receipt ?
In love mode
correct
sure, what's your question?
Once the person is on the checkout session, is there a way to trigger some code to add another constraint to the chekout validation?
Once he click on the button 'pay'
What constrains for example?
I would like to check at the very last step my product stock... so we avoid overselling
I already do it until he gets on the chekout session
but if 2 people are in the checkout session.. i don't want them both to be able to buy an article that has only 1 in stock...
I have this information in my database. I wish I'll be able to check the stock of my product at the very last click before the person pays
No that's not possible, but there is a workaround:
- Use
capute_method: manualhttps://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-capture_method - And then later only capture the funds if you have some stock left, otherwise cancel the order
It looks like this thing is plugged to a payment intend but I don't use paymentIntents
$checkout_session = Session::create([
'line_items' => $productsForStripe,
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/commande/valide/{CHECKOUT_SESSION_ID}',
'cancel_url' => $YOUR_DOMAIN . '/commande/echec/{CHECKOUT_SESSION_ID}',
]);
Should I add it there?
but I don't use paymentIntents
Checkout Session automatically create PaymentIntents for you
Yes you need to add this to your code creatig a Checkout Session:
'payment_intent_data' => [ 'capture_method' => 'manual']
And then later capture the funds with https://stripe.com/docs/api/payment_intents/capture
Alright! and then ```php
$stripe->paymentIntents->capture(
'pi_number',
[]
);
yep
The only thing I'm struggling with is getting the pi_number
can I get the payment intent ID from the response of the checkout session? and how?
Yes once the payment is successful, the Checkout Session should have a payment_intent property with the ID: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-payment_intent