#xqprtzcv-shipping-change
1 messages · Page 1 of 1 (latest)
HI 👋
Which doc are you following here?
I am looking at the stripe js docs
For example, here are the update details:
https://stripe.com/docs/js/appendix/update_details
I don't see a way to update the shipping option using javascript (like to change from free to express)
We discuss this more clearly here: https://stripe.com/docs/stripe-js/elements/payment-request-button?client=html#html-js-collecting-shipping-info
Yes, everything is working correctly except the above scenario I described.
So you are saying you do not see the shippingoptionchange event firing?
Yeah, that is correct
A potential problem is that when I am changing the shipping options in step 2 I am using the same id's that I had before. I am testing to see if I update the ids if that fixes the problem
Still seems a little hacky though
And I should mention that I see it fire the first time, but not the second time
When you say you see it fire the first time and not the second time, do you mean the shippingoptionchange event first the first time you choose a shipping option?
Yes, it fires in step 2, but not in step 4.
Before I was using objects like this for the shipping options:
{
"id": "fast",
"label": "Express (2-3 days)",
"detail": "Estimated Delivery 11/13 - 11/14",
"amount": 2087
}
and I changed it to append a time stamp to the id so now the id looks like this: 1699571970fast, and I believe it is working correclty now
So I guess when you update the shipping options, it is good to use new ids, otherwise you will run into the problem I was facing.
- I suspect that is why the reference doc shows
id: "someUniqueID",but that still isn't very useful
- That should be better documented if that is the intended use case
Yeah, and it still seems weird that I can get in a state where the displayed shipping is different than the selected shipping.
Like when you run this:
let updateDetails={
"status": 'success',
"shippingOptions":shippingOptionsArr
}
updateWith(updateDetails);
I believe it shows the first option from shippingOptionsArr as being chosen, even when the internal choice is different.
Yes we call that out here: https://stripe.com/docs/js/appendix/update_details
shippingOptions
array
An array of ShippingOption objects. The first shipping option listed appears in the browser payment interface as the default option.
xqprtzcv-shipping-change
Yes, it appears as the default option, but I believe the saved state is different which is causing the event not to fire.
Hello! Jumping in and wondering if there are any outstanding questions or issues? It sounds like you got it working?
Yes, I got it working, but might be worth you guys having a closer look at it.
Will do, thanks for the feedback!