Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECE/GooglePay/ApplePay JS error when payment fails from backend #9990

Open
frosso opened this issue Dec 18, 2024 · 1 comment
Open

ECE/GooglePay/ApplePay JS error when payment fails from backend #9990

frosso opened this issue Dec 18, 2024 · 1 comment
Assignees
Labels
component: payment request button Apple Pay, Google Pay, etc focus: checkout payments priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.

Comments

@frosso
Copy link
Contributor

frosso commented Dec 18, 2024

Describe the bug

I observed this both in the non-tokenized and the tokenized ECE.

When the backend fails a payment, we call the paymentFailed( { reason: 'fail' } ) method:

onConfirmEvent.paymentFailed( { reason: 'fail' } );

payment.paymentFailed( { reason: 'fail' } );

When this is triggered, a JS error occurs in the console:

v3/?ver=3.0:1 Uncaught (in promise) IntegrationError: Unexpected call to paymentFailed(). Ensure you are either submitting a payment or calling paymentFailed() once per expressCheckout Element confirm event.
    at v3/?ver=3.0:1:355551
(anonymous) @ v3/?ver=3.0:1
Promise.then
paymentFailed @ v3/?ver=3.0:1
abortPayment @ index.js:109
onConfirmHandler @ event-handlers.js:106
await in onConfirmHandler
eval @ index.js:335
(anonymous) @ v3/?ver=3.0:1
s._emit @ v3/?ver=3.0:1
a._emitEvent @ v3/?ver=3.0:1
N @ v3/?ver=3.0:1
(anonymous) @ v3/?ver=3.0:1
s._emit @ v3/?ver=3.0:1
_handleMessage @ v3/?ver=3.0:1
(anonymous) @ v3/?ver=3.0:1
(anonymous) @ v3/?ver=3.0:1

To Reproduce

  1. Modify the backend to fail the payment, or modify the JS to trigger this conditional:
  • (or, alternatively, use a failed card if you can)
  1. Ensure you have GooglePay/ApplePay enabled
  2. Navigate to a product page
  3. Click on the GooglePay/ApplePay button
  4. Attempt to pay
  5. JS error appears in the console

Screenshots

The screenshot shows the reCaptcha plugins failing, but I can reproduce it also without said plugin.
Image

Expected behavior

No JS error should appear when a payment fails.
It seems that we're calling paymentFailed() incorrectly.

Additional context

@frosso frosso added component: payment request button Apple Pay, Google Pay, etc focus: checkout payments priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug. labels Dec 18, 2024
@pierorocca pierorocca added priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. and removed priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. labels Dec 19, 2024
@bborman22
Copy link
Contributor

@cesarcosta99 cesarcosta99 self-assigned this Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: payment request button Apple Pay, Google Pay, etc focus: checkout payments priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.
Projects
None yet
Development

No branches or pull requests

4 participants