在Android Pay流程(getPaymentToken)之后,付款令牌变得未定义

时间:2018-12-19 14:05:24

标签: react-native braintree android-pay google-pay

我已经推荐了这个-https://github.com/naoufal/react-native-payments#readme

这是我的代码(已编辑):>

           const METHOD_DATA = [{
            supportedMethods: ['android-pay'],
            data: {
              merchantIdentifier: 'merchant.co.guru.media',
              supportedNetworks: ['visa', 'mastercard', 'amex'],
              countryCode: 'US',
              currencyCode: 'USD',
              environment: PaymentMethodKeys.environment,
              merchantInfo: {
                // A merchant ID is available after approval by Google.
                // @see {@link https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist}
                merchantId: '0xxxxxxxxxxx6',
                merchantName: 'Application_Merchant'
              },
              paymentMethodTokenizationParameters: {
                tokenizationType: 'GATEWAY_TOKEN',
                parameters: {
                  gateway: 'braintree',
                  "braintree:apiVersion": "v1",
                  "braintree:sdkVersion": '2.4.0',
                  "braintree:merchantId": "jxxxxxxxxxxxxt5",
                  "braintree:clientKey": "03xxxxxxxxxxxxxxe99",
                  'braintree:tokenizationKey': 'production_xqs_jbxxxxxxbx8249xxxxxx5',
                  publicKey: 'jxxxxxxxxxxxxxxxqt',
                }
              }
            }
          }];

 const DETAILS = {
        id: 'demo',
        displayItems: [
          {
            label: 'Movie Ticket',
            amount: { currency: 'USD', value: '15.00' }
          },
          {
            label: 'Shipping',
            amount: { currency: 'USD', value: '0.00' }
          }
        ],
        total: {
          label: 'Merchant Name',
          amount: { currency: 'USD', value: '15.00' }
        },
        shippingOptions: [
          {
            id: 'economy',
            label: 'Economy Shipping',
            amount: { currency: 'USD', value: '0.00' },
            detail: 'Arrives in 3-5 days',
            selected: true
          },
          {
            id: 'express',
            label: 'Express Shipping',
            amount: { currency: 'USD', value: '5.00' },
            detail: 'Arrives tomorrow'
          }
        ]
      };

      const OPTIONS = {
        requestPayerName: true,
        requestPayerPhone: true,
        requestPayerEmail: true,
        requestShipping: true
      };

      const paymentRequest = new PaymentRequest(METHOD_DATA, DETAILS, OPTIONS);
      paymentRequest.show()
        .then(paymentResponse => {
          const { getPaymentToken } = paymentResponse.details;
          console.log('paymentResponse', JSON.stringify(getPaymentToken))
          console.log('paymentResponse', JSON.stringify(paymentResponse))
          return getPaymentToken()
            .then(paymentToken => {
              console.log('paymentToken paymentResponse', JSON.stringify(paymentToken))
                       
            });
        });

问题在于,当我尝试执行Android Pay时,它返回“找不到记录”

获得的响应如下

  

{“ serializedPaymentToken”:“ {\”错误\“:{\”消息\“:\”不记录   found \“},\” fieldErrors \“:[]}”,“ paymentToken”:{“ error”:{“ message”:“ Record   不   找到“},” fieldErrors“:[]},” serializedPaymenToken“:” {\“ error \”:{\“ message \”:\“ Record   不   found \“},\” fieldErrors \“:[]}”,“ paymenToken”:{“ error”:{“ message”:“记录   找不到“”,“ fieldErrors”:[]}}'

因此令牌变得不确定。您能否让我知道问题可能隐藏在哪里。我应该提到的是,我在真实的设备(具有实际的Google Pay帐户)和sandBox上尝试了此代码,并且在所有情况下均失败了。

谢谢。

1 个答案:

答案 0 :(得分:0)

https://google.com/pay下使用supportedMethods而不是android-pay,以便通过Payment Request API利用Google Pay。

检查以下两个示例以进一步参考:official docssample from the Chrome team