#_liamm3
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
Can you add following in the shippingratechange event callback before resolving line items, i.e. before line 51 of your code?
elements.update({amount: result.amount})
Do you mean the shippingaddresschange? Because I don't use the shippingratechange event.^^
I added it before my resolve call but nothing changes. I also see no warning or error in my browser console. Here is the event handler for reference:
expressCheckoutElement.on('shippingaddresschange', async (event) => {
const address = event.address;
console.log("Address changed:", address);
console.log('event', event);
const res = await fetch('/actions/api-module/stripe-express/update-address', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({
address,
sku: {{ product.defaultVariant.sku }},
}),
});
const payload = await res.json();
const resolve = event.resolve;
orderId = payload.orderNumber;
elements.update({
amount: payload.total.amount,
})
resolve({
lineItems: payload.displayItems
});
// elements.fetchUpdates();
})
Thanks for the help!
Can you log the payload.displayItems and check if there is any change with the amount in the items before resolving the event?
Oh wow, I am sorry. I added the the elements.update() line to the mirror of our project with the same name. ๐ I now added it to the correct project and it's working. :D Thanks so much! You saved me a lot headache ๐
Yay! Great to hear that it works now!
I don't know if it's necessary, but maybe the docs on this should be updated and not only say 'Used with Payment Element' but also say 'Used with Express Checkout Element'? https://stripe.com/docs/js/elements_object/update ๐ค