#spider_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/1428817380259139726
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
@limpid knot Our overall goal is to allow someone, if they already have any of apple pay, google pay, link, or amazon pay, to use it for both address and payment. However, because we charges sales tax, we cannot calculate the total cost until we have their address. We’re running into problems being able to let someone do, for example, apple pay, where the total is dynamically changed in the apple pay screen as they confirm or change their address, so we are able to calculate the final amount in shippingaddresschange event, but not able to update the wallet total amount shown for user.
You should be able to use the resolve function to update the line items. There's a snippet here: https://docs.stripe.com/elements/express-checkout-element/accept-a-payment?payment-ui=elements#collect-shipping-information
const response = await fetch('/calculate-shipping', {
data: JSON.stringify({
shippingAddress: address
})
});
const result = await response.json();
resolve({
lineItems: result.updatedLineItems,
});
};```
@limpid knot Updating the line items works, but it doesn’t update the total shown on the wallet screen, as shown in the image below. How can I update that?
Did you also update the payment intent?
Yes @limpid knot , I also updated the payment intent, but it doesn’t show the updated pricing. Do we need to make a call to Stripe so it knows the payment intent was updated, or does it refresh automatically?
I thought updating line items was enough, but let me check with my colleague to get a better understanding
Thanks @limpid knot
Are you loading the element with payment intent client secret?
Or using the deferred intents flow where you just pass an amount into the element and create the payment intent later?
@limpid knot I am loading the element with payment intent client secret
Still waiting to hear back from my colleague
Ok so we're still looking into whether this is possible or not with creating intent up-front
The ECE was designed for the deferred intent flow, so this is possible in that flow
Where you pass an amount into Elements and wait to create the intent until after submitting
Here's a js fiddle of this working: https://jsfiddle.net/nolanhawkins/3zgqedf9/23/
In the deferred intent flow you update the amount on the elements object: https://docs.stripe.com/js/elements_object/update#elements_update-options-amount as well as the line items (how I showed earlier): https://docs.stripe.com/js/elements_object/express_checkout_element_shippingaddresschange_event#express_checkout_element_on_shipping_address_change-handler-resolve-lineItems
If you look at the express checkout integration guide, you'll notice that it's the deferred flow: https://docs.stripe.com/elements/express-checkout-element/accept-a-payment?payment-ui=elements
Thanks @limpid knot let me try this out