#tarantino-47_apple-pay-error

1 messages ยท Page 1 of 1 (latest)

wanton wadiBOT
#

๐Ÿ‘‹ 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.

next widget
#

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?

rotund berry
#

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

next widget
#

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.

rotund berry
#

hm, not possible, I don't have it opened anywhere

next widget
#

What browser are you loading this in?

#

Is this in your Stripe integration?

rotund berry
#

yes

#

google chrome

#

it's a production bug which I'm trying to fix right now

next widget
#

Sorry but you are still not telling me much about the actual problem here

rotund berry
#

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

next widget
#

Okay and are you explicitly disabling digital wallets in the payment element?

rotund berry
#

hm, don't think so, do you know how to check this?

hard wing
#

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

rotund berry
#

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
}
hard wing
#

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

rotund berry
#

the thing is that I'm not the only one who seeing it. almost every person can replicate it

next widget
#

Do you have a front-end that is publicly accessible where we could reproduce this error?

rotund berry
#

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

next widget
#

A test account would help, thanks

rotund berry
#

just a sec

#

go to checkout and select apple pay or google pay

next widget
#

No errors, a successful launch of the modal

rotund berry
#

hm, can you check apple pay?

next widget
#

Okay this time I got errors but not the ones you described

rotund berry
#

yes

next widget
#

In this case it looks like there are some hcaptcha calls occuring here

rotund berry
#

why whould it be related?

next widget
#

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

rotund berry
#

hm

#

you mean hcaptcha request is a part of stripe?

next widget
#

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

rotund berry
#

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

next widget
#

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

rotund berry
next widget
#

That's the page I was checking

#

Google Pay works fine, Apple Pay fails.

rotund berry
#

ok ok

rotund berry
#

hcaptcha is not really a part of our application

next widget
#

Which is really bugging me. Because it means that it isn't something obvious in your code (like loading in an iframe)

rotund berry
#

you think an iframe on our site could be a reason of failing hcaptcha which leads apple pay to fail?

next widget
#
  1. I think the hcaptcha is a red herring, not important
#
  1. I do not think this is due you using an iframe on your site.
rotund berry
#

ok , gotcha

wanton wadiBOT
rotund berry
#

I plan to disable apple pay temporarily, till I/we figure out what's the reason behind this

next widget
#

Sorry but could you share your account ID so we can check your Apple Pay domain registration?

rotund berry
#

sure

#

I'll DM you

next widget
#

I cannot receive DMs and I'm going off shift soon so my colleague @vast echo will likely continue on here.

wanton wadiBOT
#

tarantino-47_apple-pay-error

rotund berry
#

can i delete the key from chat?

vast echo
#

Hi ๐Ÿ‘‹ jumping in as my teammate needs to step away soon. I'm not seeing a key shared in this thread.

rotund berry
#

sorry account id

#

this one acct_19ByUbFbFOzNrsPE

vast echo
#

Then I won't have it for reference though, those IDs aren't sensitive

rotund berry
#

I see

vast echo
#

Hm, nothing's jumping out at me so far. Still digging.

rotund berry
#

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

vast echo
#

Can you share the code you're using to initialize the instance of Elements, and of the Payment Element instance, that you're using?

rotund berry
#

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>
  );
vast echo
#

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.

rotund berry
#

ah, I remember I faced this issue before

#

well

#

just a sec

vast echo
#

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.

rotund berry
#

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.

vast echo
rotund berry
#

yes

vast echo
#

Gotcha

rotund berry
#

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

vast echo
#

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.

rotund berry
#

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

vast echo
#

Hm, yeah I'm not seeing that behavior. I'm seeing matching amounts on my end:

rotund berry
#

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

vast echo
#

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?

rotund berry
#

yes it's before

#

I do this first:
elements.update({
mode: 'payment',
paymentMethodTypes: ['card'],
amount: formatPlatformPayPrice(amount),
});

vast echo
#

That should be fine then

rotund berry
#

yea it's fine, but amount in the gpay modal is not being updated

vast echo
#

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?

rotund berry
#

no, you know, I think I resolved it

#

thank you so much!

#

have a good day!