google-pay / google-pay-button

Google Pay button - React, Angular, and custom element
Apache License 2.0
255 stars 62 forks source link

Google Pay button breaks with a stack trace when buttonType = (anything other than 'buy') #148

Closed jroyals closed 1 year ago

jroyals commented 2 years ago

Describe the bug

Sorry I'm not sure if this is the right repo to report this but it's the closest I can find.

We use the Google Pay React button library in our project. Today we received reports our checkout was broken. Upon investigation we discovered that the "buttonType" property is causing an issue.

If a site specifies a buttonType that is anything other than "buy", pay.js will throw an exception and cause an error. In our situation the page became stuck and unresponsive. Once I removed this property and allowed the default, it worked again.

I can reproduce this on the Google demo site.

To Reproduce

  1. Go to 'https://developers.google.com/pay/api/web/guides/resources/customize'
  2. Observe a Google Pay button is shown
  3. Click the "buttonType" and select some other value than "buy"
  4. Observe the button disappears and a stack trace is shown in the developer console

In this stack trace example I changed the buttonType to "donate" and it seems it is trying (and failing) to read a property of that string value.

pay.js:275 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'donate')
    at m.pa (pay.js:275:150)
    at m.pa (pay.js:286:382)
    at l.<anonymous> (index.umd.min.js:15:4764)
    at Generator.next (<anonymous>)
    at index.umd.min.js:15:692
    at new Promise (<anonymous>)
    at e (index.umd.min.js:15:437)
    at l.updateElement (index.umd.min.js:15:4150)
    at l.configure (index.umd.min.js:15:2849)
    at index.umd.min.js:15:8645

Expected behavior

It works as we would expect

Component information:

At least the pay.js component.

Environment:

Reproduced on Chrome for Windows, Chrome for Android and Chrome for iOS.

AliSaberi commented 2 years ago

I have the same issue ! there is a problem inside pay.js

eardenercruk commented 2 years ago

Same issue, reverting to logo-only for now but since 11pm last night we've not been able to take GPay payments because of the button not rendering with 'donate' or 'pay'. We haven't done a release, this appears to be an issue with externally-hosted pay.js.

ipetrovbg commented 2 years ago

Same here, the only options that work for me are buy, plain, short and long

debajitr commented 2 years ago

Same here.

hasheri commented 2 years ago

Same here Is there a way to catch the error and hide the button?

bondars95 commented 2 years ago

Same for us, is there any way to load some exact version of pay.js?

iandodds75 commented 2 years ago

Same here. If I revert button type to "buy" as mentioned above then it works although we prefer the "pay" option

jroyals commented 2 years ago

The Google demo site is working again, I assume the underlying issue was fixed?

dmengelt commented 1 year ago

this was a temporary issue.