#Janus Reith-google-pay-shipping-address
1 messages · Page 1 of 1 (latest)
Hi @signal sparrow !
So I understand correctly, you're struggling with the Google Pay interface in Chrome not firing an expect Stripe.js event, right?
Yes, correct. Or, either that, or I'm struggling to find another way to make sense of how to handle shipping calculation
Maybe there's some totally different possibility which doesn't need to make Chrome fire that adress initially.
Something along the lines of me passing data as "Hey, here is a total and selected address, assuming your address is a DE address. If it's not, don''t preselect that address since it isn't valid" - Something like that, however it seems like I can only in general specifiy allowed countries, not something like "assumed default country"
Got it. I believe this is a Chrome implementation issue with the Payment Request API (browser API behind all this stuff)
Yeah I got the same impression
Like, we're at the mercy of the browsers and how they implement this stuff unfortunately
Let me see if I can find anything to confirm my hypothesis
I tried to workaround this in a not that fancy way, by trying to check egilibility of the currently selected fulfilment method in the paymentmethod event fired afterwards to complete the payment flow. That way a user would need to click confirm in the modal once and fail, and then maybe change their address, not optimal but at least it would keep the things contained within that payment modal I hoped. That however doesn't seem to work either, I can't use sth. like event.updateWith as we have for the shippingaddresschange event, but all I can do is complete("fail") (or "success" certainly) , if I call that however, Chrome will show a generic payment error screen and I can't continue the flow either.
Oh wow okay it looks like there is an interesting "fix" for this 🤦♂️ :
I leave requestShipping as true like before.
But, I just dont pass shippingOptions as an array anymore.
That way, collecting shopping still works appareantly, and won't preselect a shipping address.
So, shipping options will only be available after that address selection, which TBH also makes sense
The user has to then select their address, rather than the default being prefilled?
Yes exactly
Meaning I can always update the available fulfilment options, and also handle them not being availble propery.
Like, selecting a FR address returns a more expensive international shipping option, selecting a US address shows an error that no shipping is available for that country, just like it is supposed to work.
I mean, would be cool to have a preselected address and save one checkout step, and knowing that the majority of my users is from germany, have the fulfilment options for that right at hand initially, but I can totally live with that solution now.
That seems like a worthwhile trade-off for this to work as you need!
Indeed. I feel like this could be documented somewhere. While the Stripe Docs are pretty comprehensive already, getting the PaymentRequest API right still gets complicated here and there