#yogooooooo_unexpected
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/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.
- yogooooooo_code, 20 hours ago, 13 messages
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?
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
What is condition here?
I removed it but it's an ID that I need to pass into the putShippingAddressToBasket call
Alright give me a min to see if I can repro
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.
You mean it isn't updating after you update server-side?
Are you calling fetchUpdates()? (https://docs.stripe.com/js/elements_object/fetch_updates)
Err wait that's not relevant here for ExpressCheckoutElement
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})
You set the amount client-side
With Express Checkout Element the amount is initially set via the elements object: https://docs.stripe.com/js/elements_object/create_without_intent#stripe_elements_no_intent-options-amount
Updating the PaymentIntent doesn't have any affect on what is shown client-side.
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
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.
Lahdy lol ok let me see if that changes anything
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
Surely
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
Can you share your exact code (all relevant parts) and a screen recording of what you are seeing with your console open?