#_liamm3

1 messages ยท Page 1 of 1 (latest)

past vergeBOT
#

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.

  • _liamm3, 18 hours ago, 24 messages
  • _liamm3, 22 hours ago, 7 messages
marble imp
#

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})
summer sleet
#

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!

marble imp
#

Can you log the payload.displayItems and check if there is any change with the amount in the items before resolving the event?

summer sleet
#

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 ๐Ÿ˜„

marble imp
#

Yay! Great to hear that it works now!

summer sleet