question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Cannot read property 'includes' of undefined" when setting environment to "PRODUCTION"

See original GitHub issue

Describe the bug When setting environment as PRODUCTION and using existingPaymentMethodRequired flag, getting Cannot read property 'includes' of undefined error and the Google Pay button no longer shows up.

To Reproduce Steps to reproduce the behavior:

  • implement Google Pay React component
  • set environment to “PRODUCTION” mode
  • set existingPaymentMethodRequired to true
  • see error

Expected behavior Except Google Pay button to show up

Screenshots Screen Shot 2021-02-25 at 12 23 23 PM

Component information:

  • Component
    • React component (@google-pay/button-react)
  • Component version (e.g. 1.0.0): 2.2.1

Environment:

  • Device: MacBook Pro (15-inch, 2019)
  • OS: Catalina 10.15.7
  • All browsers
  • Country/region: US

Additional context

  • Our domain is verified for production in the Google Pay console
  • The button works fine when set to TEST
  • Verified that we are using the correct merchant ID

Here is the code used to render the button:

<GooglePay
            existingPaymentMethodRequired
            className="google-pay-button"
            environment="PRODUCTION"
            environment={
              process.env.CALM_ENV === 'production' ? 'PRODUCTION' : 'TEST'
            }
            buttonType="plain"
            buttonSizeMode="fill"
            paymentRequest={{
              apiVersion: 2,
              apiVersionMinor: 0,
              allowedPaymentMethods: [
                {
                  type: 'CARD',
                  parameters: {
                    allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
                    allowedCardNetworks: ['MASTERCARD', 'VISA'],
                  },
                  tokenizationSpecification: {
                    type: 'PAYMENT_GATEWAY',
                    parameters: {
                      gateway: 'stripe',
                      'stripe:version': '2018-10-31',
                      'stripe:publishableKey': process.env.STRIPE_TOKEN,
                    },
                  },
                },
              ],
              merchantInfo: {
                merchantId: process.env.GOOGLE_PAY_MERCHANT_ID,
                merchantName: 'Calm',
              },
              transactionInfo: {
                totalPriceStatus: 'FINAL',
                totalPriceLabel: 'Total',
                totalPrice:
                  purchaseType?.type === 'freetrial'
                    ? '00.00'
                    : (prices?.current[plan] / 100).toString(),
                currencyCode: prices?.current?.currency || 'USD',
                countryCode: 'US',
              },
            }}
            onLoadPaymentData={paymentRequest => {
              const stripeToken = JSON.parse(
                paymentRequest?.paymentMethodData?.tokenizationData?.token,
              );
              onSubmit(stripeToken);
            }}
            onReadyToPayChange={({ isReadyToPay }) =>
              setIsGoogleAvailable(isReadyToPay)
            }
          />

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
socsiengcommented, Feb 25, 2021

Got it on the second try: image

Testing it out now.

0reactions
mbillzcommented, Feb 26, 2021

Ah yes, I always forget about React Dev Tools. Thanks for your help! I’m good to close this, I have a solid direction.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Routing error in dev mode: TypeError: Cannot read property ...
I only found one issue #5109 #5109 about TypeError: Cannot read property 'page' of undefined and it seems entirely offbase.
Read more >
JavaScript error: Cannot read property 'includes' of undefined
It's telling you that you're trying to access a property on an undefined object. The msgArr object doesn't have a property objectID at...
Read more >
Avoiding those dang cannot read property of undefined errors
Uncaught TypeError : Cannot read property 'foo' of undefined. ​ The dreaded error we all hit at some point in JavaScript development.
Read more >
Uncaught TypeError: Cannot read property of undefined In
This error occurs in Chrome Browser when you read a property or call a method on an undefined object . There are a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found