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

Merchant not enabled for Google Pay #111

Open KthProg opened 6 years ago

KthProg commented 6 years ago

It's not clear how I would enable my account for Google Pay and following the docs exactly does not work. I am trying to use Stripe although I would be fine with using Google Pay directly.

KthProg commented 6 years ago

In test mode it works fine, in that case I don't get a token back though.

KthProg commented 6 years ago

It looks like the onActivityResult callback is not being called

KthProg commented 6 years ago

It appeared to be fixed by adding this to my main activity class:


  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    ((ReactInstanceManager)(Object)mReactInstanceManager.get()).onActivityResult(this, requestCode, resultCode, data );
  }
KthProg commented 6 years ago

Based on this issue: https://stackoverflow.com/questions/36335484/react-native-onactivityresult-not-work

KthProg commented 6 years ago

The original issue still remains. This only fixes the issue in the TEST environment.

KthProg commented 6 years ago

@naoufal Any idea what's causing this?

KthProg commented 6 years ago

Here's my code (edited):

import React from 'react';
import { View } from 'react-native';
import { PaymentRequest } from 'react-native-payments';
import { logger } from 'react-native-logger';

export default class Market extends React.Component {
  static paymentMethodData = [{
    supportedMethods: ['android-pay'],
    data: {
      supportedNetworks: ['visa', 'mastercard', 'amex'],
      currencyCode: 'USD',
      //environment: 'TEST',
      paymentMethodTokenizationParameters: {
        tokenizationType: 'GATEWAY_TOKEN',
        parameters: {
          gateway: 'stripe',
          'stripe:publishableKey': Defaults.stripePubKeyLive,
          'stripe:version': '2018-07-27' // Only required on Android
        }
      }
    }
  }];

  constructor(props){
    super(props);
    // ...
  }

  purchaseCard(card){
    const paymentDetails = {
      displayItems: [
        {
          label: 'CardLife Market - ' + card.name,
          amount: { currency: 'USD', value: card.cost }
        }
      ],
      total: {
        label: '2e Soft',
        amount: { currency: 'USD', value: card.cost }
      }
    };
    const paymentRequest = new PaymentRequest(Market.paymentMethodData, paymentDetails);
    paymentRequest.show().then(paymentResponse => {
      const { getPaymentToken } = paymentResponse.details;
      return getPaymentToken()
        .then(paymentToken => {
          // server code here
        }).catch(failure => {
          paymentResponse.complete('failure');
        });
    }).catch(failure => {
      paymentRequest.abort();
    })
  }

  render() {
    return (
      <View>
          // ...
      </View>
    );
  }
}
KthProg commented 6 years ago

It looks like you have to request production access for your merchant id. THis should be included in the documentation: (https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist)

ChiragJadav-Bacancy commented 5 years ago

I'm facing same issue and I am Implement this library https://github.com/JadavChirag/react-native-GPay. and Its working fine for me. It build production and development fine as well as :)

mihir-bacancy commented 5 years ago

I'm facing same issue and I am Implement this library https://github.com/JadavChirag/react-native-GPay. and Its working fine for me. It build production and development fine as well as :)

Thanks Its also work for me. :)