4

When I try to pay(on TEST environment) with Google Pay on a real device I get a the error in the title.

I have tried changing 'gateway' into a string like the google docs show it but so far nothing.

const DETAILS = {
id: 'COMPANY',
displayItems: [
  {
    label: 'Phone Bill',
    amount: { currency: 'USD', value: compTotal }
  }
],
total: {
  label: 'COMPANY',
  amount: { currency: 'USD', value: compTotal }
}
};

// GOOGLE PAY
const METHOD_DATA = [{
  supportedMethods: ['android-pay'],
  data: {
    supportedNetworks: ['visa', 'mastercard', 'amex'],
    currencyCode: 'USD',
    environment: 'TEST', // defaults to production
    paymentMethodTokenizationParameters: {
      tokenizationType: 'GATEWAY_TOKEN',
      parameters: {
        gateway: 'braintree',
        'braintree:tokenizationKey': 'sandbox_XXXXXXXXXXX'
      }
    }
  }
}];

const paymentRequest = new PaymentRequest(METHOD_DATA, DETAILS);

paymentRequest.show()
.then(paymentResponse => {
  const { getPaymentToken } = paymentResponse.details;

  return getPaymentToken()
    .then(paymentToken => {
      const { ephemeralPublicKey, encryptedMessage, tag } = paymentToken.details;

      return fetch('...', {
        method: 'POST',
        body: {
          ephemeralPublicKey,
          encryptedMessage,
          tag
        }
      })
      .then(res => res.json())
      .then(paymentResponse.complete('success'), handleConfirm())
      .catch(paymentResponse.complete('fail'), alert(1));
    });
});
};

Expected result would be the payment going through.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Owpur
  • 203
  • 1
  • 3
  • 12

4 Answers4

8

To learn more about this error, follow these steps:

1- Make sure Android Debug Bridge (adb) is installed on your computer.. Make sure USB debugging is enabled on your device. For more information, see Debug Your App.

2- Connect your phone to the computer with a USB cable.

3- Run the following command in a terminal or command prompt on your computer:

adb -d logcat -s WalletMerchantError
Kratos
  • 329
  • 3
  • 4
4

Turns out I was not able to do this with React-Native because 'React Native Payments' did not fully support Google Pay which in turn did not fully support Braintree & didn't support Payeezy at all.

I had to resort to native code(Java) and then link React-Native to that native module. It was pretty simple.

I used this demo on Github to guide me through it. I was using Braintree as the payment processor but looks like I will be switching to Payeezy.

I was getting the error in the title because like I said Google Pay wasn't supported fully by 'React-Native-Payments' which in turn didn't support Braintree and when the error was accuring because I was only giving this info -

parameters: {
  gateway: 'braintree',
  'braintree:tokenizationKey': 'sandbox_TOKEN-HERE'
}

But looks like I needed to use this(In the Java Module) -

.put("gateway", "braintree")
.put("braintree:apiVersion", "v1")
.put("braintree:sdkVersion", "BETA")
.put("braintree:clientKey", "sandbox_TOKEN-HERE")
.put("braintree:merchantId", "TOKEN-HERE"));
Owpur
  • 203
  • 1
  • 3
  • 12
2

I have the some error because of mismatch type of price object. I put the float value in totalPrice. After update

data class TransactionInfo(
        @SerializedName("totalPrice") val price: String,
        @SerializedName("totalPriceStatus") val priceStatus: String,
        @SerializedName("currencyCode") val currency: String
)

This is works fine on ENVIRONMENT_TEST case.

Vahe Gharibyan
  • 5,277
  • 4
  • 36
  • 47
0

Use https://google.com/pay under supportedMethods to leverage Google Pay through Payment Request API.

Check these couple of examples for further reference: official docs, sample from the Chrome team.

Jose L Ugia
  • 5,960
  • 3
  • 23
  • 26