"Cannot read property 'includes' of undefined" when setting environment to "PRODUCTION"
See original GitHub issueDescribe 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
totrue
- see error
Expected behavior Except Google Pay button to show up
Screenshots
Component information:
- Component
- React component (
@google-pay/button-react
)
- React component (
- 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:
- Created 3 years ago
- Comments:14 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Got it on the second try:
Testing it out now.
Ah yes, I always forget about React Dev Tools. Thanks for your help! I’m good to close this, I have a solid direction.