#tarantino-47_apple-pay-error
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1261008283553108048
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hi ๐
Can you explain exactly when you see this error?
What stripe products are you using?
What point in your checkout flow does this occur?
when I try to pay using apple pay or google pay
Something went wrong. Unable to show Google Pay. Please choose a different payment method and try again
Okay this error generally means the Apple/Google pay modal is open on another tab. At least that is the only away I've been able to reliably reproduce that behavior
Tab, window, browser, etc.
hm, not possible, I don't have it opened anywhere
Sorry but you are still not telling me much about the actual problem here
I'm using Payment Element and Payment Request Button. I don't use them on the same page. I use them in a diff pages only
Okay and are you explicitly disabling digital wallets in the payment element?
hm, don't think so, do you know how to check this?
Is there a way to reproduce your bug easily? Like this error usually just means you have another Chrome window that is already showing the PaymentRequest UI and you forgot to cancel it/close it
there is one thing, I am ignoring the incomplete error in my stripe integration. but it should not be related I think:
const { error: submitError } = await elements.submit();
if (submitError?.code === 'incomplete') {
// just ignore it and stop submit function
}
My read is that you are already doing PaymentRequest somewhere else. Maybe try closing all your Chrome windows first or rebooting to see if that fixes it?
Also you definitely should handle the error if any
the thing is that I'm not the only one who seeing it. almost every person can replicate it
Do you have a front-end that is publicly accessible where we could reproduce this error?
Also you definitely should handle the error if any
I just wanted to not show an error if a user closes google pay of apple pay modal
yes
you'll need to create an account. or I can do that for you
A test account would help, thanks
vlad+teststripe@usmobile.com
Test123$
just a sec
go to this page:
https://app.usmobile.com/dashboard/app/new-plan-checkout?category=FT
go to checkout and select apple pay or google pay
No errors, a successful launch of the modal
hm, can you check apple pay?
Okay this time I got errors but not the ones you described
yes
In this case it looks like there are some hcaptcha calls occuring here
why whould it be related?
Apple Pay will fail to load if there are other processes like hcaptcha that run between when the user clicks the "Pay" button and when the Apple Pay UI is displayed
I would need to verify that. I just had someone add captcha to their checkout flow and it broke their apple pay integration because of where they put it, so I want to rule that out
hm
can you please update me once you have any updates
wonder if I need to send a ping message to this thread so it won't close
Well I'm digging around through your front-end but it's really strange. I don't see any errors when using Google Pay in Chrome but Apple Pay in Safari fails every time
you only need to check this page
https://app.usmobile.com/dashboard/app/new-plan-checkout?category=FT
since this is the most recent changes, which include Payment Element
ok ok
hcaptcha is not really a part of our application
Which is really bugging me. Because it means that it isn't something obvious in your code (like loading in an iframe)
you think an iframe on our site could be a reason of failing hcaptcha which leads apple pay to fail?
- I think the hcaptcha is a red herring, not important
- I do not think this is due you using an iframe on your site.
ok , gotcha
I plan to disable apple pay temporarily, till I/we figure out what's the reason behind this
Sorry but could you share your account ID so we can check your Apple Pay domain registration?
I cannot receive DMs and I'm going off shift soon so my colleague @vast echo will likely continue on here.
tarantino-47_apple-pay-error
can i delete the key from chat?
Hi ๐ jumping in as my teammate needs to step away soon. I'm not seeing a key shared in this thread.
Then I won't have it for reference though, those IDs aren't sensitive
I see
Hm, nothing's jumping out at me so far. Still digging.
thank you
so the thing is that apple pay works when I use Payment Request Button. When I use Payment Element it throws an error
Payment Element is withing this flow
https://app.usmobile.com/dashboard/app/new-plan-checkout?category=FT
Can you share the code you're using to initialize the instance of Elements, and of the Payment Element instance, that you're using?
in other places we use Payment REuest Button
sure
const stripePromise = loadStripe(appConfig.stripeKey);
const options = {
currency: 'usd',
loader: 'always',
mode: 'setup',
};
function Provider({ children, ...rest }: ProviderProps): React.ReactNode {
if (!rest?.isAddCardFlow) {
// it's needed for the confirmationToken creation
options.paymentMethodCreation = 'manual';
}
return (
<Elements options={options} stripe={stripePromise}>
{children}
</Elements>
);
}
useEffect(() => {
return () => {
setFormState({ isFormRendered: false });
};
}, []);
return (
<div style={{ minHeight: 180 }} className={className}>
<PaymentElement
options={{
layout: {
type: 'accordion',
defaultCollapsed: false,
radios: true,
spacedAccordionItems: false,
},
// paymentMethodOrder: ['google_pay', 'apple_pay', 'card'],
paymentMethodOrder: ['google_pay', 'card'],
wallets: {
googlePay: isAddCardFlow ? 'never' : 'auto',
// applePay: isAddCardFlow ? 'never' : 'auto',
applePay: 'never',
},
}}
onChange={handlePaymentElementChange}
onReady={handlePaymentElementReady}
/>
</div>
);
Ah, I think I remember what this may be. How are you calling confirmPayment? I think it's probably too far from being directly called by the user input from the browser.
Sure thing! Apple is pretty picky about their modal being surfaced by the user input. I've seen two different forms of limitations they have in place to help enforce that. One is that the modal's display can't be delayed by more than about a second from form submission, but I'm getting the sense the error is showing up before that. So I think we're looking at the other limitation, where they block you from showing the modal if you do so too far down in a stack of functions.
Last time I saw this, it was because there was captcha code being called on form submit, and that captcha code was then trying to call confirmPayment.
yo bro, I think youre right
checking
so yes, basically that was the reason
awesome, but I have a question
this is my code:
const handlePrePayment = async () => {
await updateStripeForm();
await new Promise((resolve) => setTimeout(() => resolve(user), 500));
await validateStripeForm();
await createConfirmationToken();
};
const updateStripeForm = () => {
if (isPaymentIntentFlow) {
elements.update({
mode: 'payment',
paymentMethodTypes: ['card'],
amount: formatPlatformPayPrice(amount),
});
}
}
I added my custom timeout, in order to fix this:
IntegrationError: You cannot update Payment Request options while the payment sheet is showing.
Oh, it looks like you're building a two step confirmation flow, where you're trying to create a Payment Method first. Does that sound right?
https://docs.stripe.com/payments/build-a-two-step-confirmation
If so it's actually the calling of .submit that we're interested in. Sorry about the mixup.
yes
Gotcha
your guess was correct
once I removed my custom timeout - apple pay started working
but in google pay an amount is 0 istead of 100
that's why I added my custom timeout, so that the 100 price propagated to the google pay modal
Hm, am I looking at the wrong test flow? I'm seeing an amount of $45 on your checkout page, then seeing the same amount in the GPay modal.
but in the other hand that timeout broke apple pay
yes, 45 sorry
i mean it doesnt really matter how much
in google pay it's 0
you may not see this case n the link I sent you
sorry, did you get what I mean
Hm, yeah I'm not seeing that behavior. I'm seeing matching amounts on my end:
yes it will work fine as in production we have that custom timeout I added to fix that
but it broke apple pay on the other hand
Im not sure what to do
It's hard to think about what could be going wrong for a flow I can't see. Is the error you're describing still being encountered even when you're using the Payment Element?
When are you trying to update the Elements instance in your flow? Is that before you call .submit?
yes it's before
I do this first:
elements.update({
mode: 'payment',
paymentMethodTypes: ['card'],
amount: formatPlatformPayPrice(amount),
});
That should be fine then
yea it's fine, but amount in the gpay modal is not being updated
I'm sorry, it's really hard for me to grasp what you're describing. If elements.update succeeds, the amount displayed should be updated. Are there errors being thrown when you call that?