stripe-archive / stripe-payments-demo

Sample store accepting universal payments on the web with Stripe Elements, Payment Request, Apple Pay, Google Pay, Microsoft Pay, and the PaymentIntents API. 💳🌍✨
https://stripe-payments-demo.appspot.com
MIT License
1.47k stars 547 forks source link

ApplePay button via PaymentRequestButtonElement fails with "Page already has an active payment session." #158

Open firemuzzy opened 4 years ago

firemuzzy commented 4 years ago

Bug report

Describe the bug

Apple pay button fails with "InvalidAccessError: Page already has an active payment session." after opening and closing it a couple of times.

You do not have such a problem on your apple pay marketing page https://stripe.com/apple-pay

Not sure where to file this I am seeing this in my usage of <PaymentRequestButtonElement>, and it also shows up in this demo app.

Is there a know work around other than reloading the page? This is a pretty bad bug for SPA applications.

To Reproduce

Expected behavior

The Apple Pay button should always summon the pay sheet

Screenshots

image

I have a video too but I need to blur out my address. If somebody can tell me of a free or cheap software I can use to blur out the address from the apple pay sheet then i'll post the video too.

If applicable, add screenshots to help explain your problem.

System information

Additional context

firemuzzy commented 4 years ago

not reproducible on iOS 14.0

hofman-stripe commented 4 years ago

I cannot reproduce, my device is on iOS 14.

It's also an error thrown and passed through from ApplePay itself. Can you reproduce on Apple's own demo site?

firemuzzy commented 4 years ago

@hofman-stripe it is not reproducible on apple's demo site. It looks to be a combination of stripe implementation and older iOS versions, unfortunately i can't update to 13.5 through 13.7 as its 14 only now so I can't test those version :-( . I can't quite tell where this bug stops.

I still get a lot of 13.6 and up traffic onto the site I ant to use this on.

saket1singh commented 3 years ago

Hi @firemuzzy .

Did you find any solution on this ? I am also facing same issue in IOS and IPAD.

Isakdl commented 3 years ago

Any news on this? I'm receiving this error from users with ios 14.6 as well as older ios 13 versions.

nopelluhh commented 3 years ago

For anybody else running into this issue, the error is reproducible (both in this demo and Apple's demo per @hofman-stripe 's callout) by double/rage clicking the ApplePay button. I believe this might be fixable on the Stripe side of things with a no-op for calls to paymentRequest.show() until the returned promise is not pending (also equally fixable in userland if a bit inconvenient)

andreimc commented 3 years ago

we see a lot of these @nopelluhh how do we fix in userland ?

simonsmith commented 2 years ago

Can confirm that @nopelluhh is correct on the diagnosis. We currently see a lot of this in our logs. One possible solution we are investigating is disabling the button submit and enabling on cancel event:

  const [disabled, setDisabled] = useState(false);

  const handleSubmit = (event: React.MouseEvent<HTMLButtonElement>) => {
    event.preventDefault();
    setDisabled(true);
    paymentRequest?.show();
  };

   paymentRequest.on('cancel', () => {
      setDisabled(false);
   });

Haven't tested this robustly yet

Edit: I am recreating this on desktop Safari. But all our Sentry logs show the users encountering the issue on mobile iOS 14/15

ankurk91 commented 2 years ago

Screenshot_2022-03-29-23-05-56-31_e307a3f9df9f380ebaf106e1dc980bb6__01

I can see same error on Sentry.