#yogooooooo_unexpected

1 messages ¡ Page 1 of 1 (latest)

wintry raftBOT
#

👋 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/1390057784220979391

📝 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.

strange acorn
#

Hi there

#

Interesting... I would indeed expect the shippingaddresschange Event to fire each time a new address is selected.

#

Can you show me your code?

near storm
#

Sure, give me a moment to get it

#

onShippingAddressChange={async ({
name,
address,
resolve,
}: StripeExpressCheckoutElementShippingAddressChangeEvent) => {
if (condition) {

                // Update the cart to calculate shipping & taxes
                const [firstName, ...theRest] = name.split(' ');
                const lastName = theRest.join('');
                const transformedCart = await putShippingAddressToBasket(
                    {
                        firstName,
                        lastName,
                        fullName: name,
                        city: address.city,
                        postalCode: address.postal_code,
                        stateCode: address.state,
                        countryCode: address.country,
                    },
                );

                // call to update cart in redux

                const lineItems = [
                    {
                        name: 'Grand Total',
                        amount: transformedCart?.total
                    },
                ];

                const shippingRates = await getShippingRates();

                await update(
                    transformedCart?.total,
                    transformedCart?.currency,
                );

                if (shippingRates) {
                    resolve({
                        shippingRates,
                        lineItems,
                    });
                }
            }
        }}
#

In the update function I update the payment intent and call elements.update with the new amount

strange acorn
#

What is condition here?

near storm
#

I removed it but it's an ID that I need to pass into the putShippingAddressToBasket call

strange acorn
#

Alright give me a min to see if I can repro

near storm
#

There's another problem where the apple sheet UI amount isn't updating ever so it might be something else causing the problems but I'm kind of at a loss at this point.

strange acorn
#

You mean it isn't updating after you update server-side?

#

Err wait that's not relevant here for ExpressCheckoutElement

near storm
#

That's right, I started by just updating the payment intent. Then thought resolve() would do the UI update. Then tried elements.fetchUpdates(), then tried elements.update({newAmount})

strange acorn
#

You set the amount client-side

#

Updating the PaymentIntent doesn't have any affect on what is shown client-side.

near storm
#

When I've tried to add amount to the initial options I get an ESLint error stating amount doesn't exist on 'StripeElementsOptionsClientSecret' and I didn't specifically type it as such

strange acorn
#

You shouldn't be passing a client secret here if you are using Express Checkout Element.

#

So you are using the wrong type in that case.

near storm
#

Lahdy lol ok let me see if that changes anything

strange acorn
#

Okay I am seeing the shippingAddressChange Event fire each time

#

So there is something else going on here

#

Can you take away all of your other code related to that and just do the most simple implenentation -- make sure you are resolving each time with a hard coded line item

near storm
#

Surely

near storm
#

Ok, in the elements options i have the mode, currency, appearance, and amount. In the onChange events (shipping and rate) I am just resolving.

With the above - I want to say obviously the UI isn't updating BUT the shipping address still isn't getting called when the shipping address is changed after the first time it's changed when the sheet loads.

#

In other words, sheet loads and changes the address using the onchange then if the user changes their address again nothing happens

strange acorn
#

Can you share your exact code (all relevant parts) and a screen recording of what you are seeing with your console open?