naoufal / react-native-payments

Accept Payments with Apple Pay and Android Pay using the Payment Request API.
https://www.npmjs.com/package/react-native-payments
1.59k stars 413 forks source link

JSON Parse error: Unexpected Error on Android #151

Open dachinat opened 5 years ago

dachinat commented 5 years ago

Hello, I'm using GooglePay with Braintree on Android like so:

const METHOD_DATA_ANDROID = [{
      supportedMethods: ['android-pay'],
      data: {
        supportedNetworks: ['visa', 'mastercard'],
        currencyCode: 'USD',
        environment: 'TEST', // defaults to production
        paymentMethodTokenizationParameters: {
          tokenizationType: 'GATEWAY_TOKEN',
          parameters: {
            gateway: 'braintree',
            //'publicKey': this.props.client.token,
            'braintree:merchantId': 'yyyyyyyyyyyy',
            'braintree:apiVersion': '2.22.0',
            'braintree:sdkVersion': '2.0.1',
            'braintree:clientKey': 'sandbox_xxxxxxxxxxxxx',
          }
        }
      }
    }];

And I'm getting JSON Parse error screen when this code is reached

const paymentToken = await getPaymentToken(); // <----
console.log(paymentToken);

Please help with this one out. Thanks.

dachinat commented 5 years ago

I solved this by modifying JS code in package, to try to JSON.parse and catch. But now paymenteToken is "".

wkoutre commented 5 years ago

@dachinat If you want, you can use my fork: https://github.com/wkoutre/react-native-payments. I was experiencing many issues, this being one of them. You should find them cleared up.

Doesn't seem like PRs are being looked at on this repo anymore.

dachinat commented 5 years ago

@wkoutre Thanks a lot great help