#wagamumma_best-practices
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/1369605985357922346
📝 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.
- wagamumma_best-practices, 22 hours ago, 34 messages
- wagamumma_webhooks, 4 days ago, 14 messages
- wagamumma_webhooks, 5 days ago, 17 messages
$intent = $stripe->paymentIntents->create
(
[
// To allow saving and retrieving payment methods, provide the Customer ID.
'customer' => $customer->id,
'amount' => 1099,
the 'amount' here I need to get the base amount (which I can get from the website, but the shipping amount is changed in the express checkout (google pay etc) how do I get this shipping amount at this stage is there a $intent->shippingAmount sort of thing?
hi there!
I'm not sure I understand your question. what do you mean by "at this stage"? can you share a concrete example of the flow you are trying to achieve?
yeh sorry, so for example in the JS I can now get the total of the order to update based on which shipping amount they choose and that works and shows the total as say £50+£5.99 shipping so the total is £55.99
then it sends the "payment intent" when they submit
but in the php example in the Docs the payment amount there is hard coded as '1099'... I wondered if instead this php can access the amount being submitted through the payment intent it creates
like $paymentIntent->ShippingAmount
because at the moment I have this which is just the base amount the website has (the website doesn't know which shipping they picked from the google pay express checkout)
$stripe = new \Stripe\StripeClient($stripeSecretTestKey);
$paymentIntent = $stripe->paymentIntents->create([
'amount' => get_cart_total()*100,
'currency' => 'gbp',
'automatic_payment_methods' => ['enabled' => true],
I need something likee:
'amount' => get_cart_total()*100+$stripe->paymentIntents->shippingValue,
because otherwise the intent amount total won't match the proper total including whichever shipping they chose at express checkout?
you want to retrieve the shipping rate selected in the Express Checkout Element? if so, you can use expressCheckoutElement.on('shippingratechange', ...). this is explained here: https://docs.stripe.com/elements/express-checkout-element/accept-a-payment#collect-shipping
yeh that bit works but that is the javascript ? so it updates fine in the javascript but when they submit the payment it calls the payment intent page (PHP) so submit the payment, but the total here won't include the shipping rate they selected but we need to get that value somehow
I guess the only other way is to store it in the database whenever the shipping rate changes, but for speed I wondered if the $stripe->paymentIntents object contains the shipping rate anywhere?
i think I'm not explaining it very well 😆 I will just try and store the shipping rate in the database on shippingRateChange instead