【问题标题】:Payment token becomes undefined after the Android Pay process (getPaymentToken)在 Android Pay 流程 (getPaymentToken) 之后,支付令牌变得未定义
【发布时间】:2019-05-20 01:05:05
【问题描述】:

我已经提到了这个 - 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":"{\"error\":{\"message\":\"不记录 找到\"},\"fieldErrors\":[]}","paymentToken":{"error":{"message":"记录 不是 找到"},"fieldErrors":[]},"serializedPaymenToken":"{\"error\":{\"message\":\"记录 不是 找到\"},\"fieldErrors\":[]}","paymenToken":{"error":{"message":"记录 未找到"},"fieldErrors":[]}}'

因此令牌变得未定义。你能告诉我问题可能隐藏在哪里吗?我应该提一下,我在真实设备(使用实际的谷歌支付账户)和沙盒上尝试了这段代码,但在所有情况下它都失败了。

提前致谢。

【问题讨论】:

  • 全面披露:我在 Braintree 工作。如果您还有其他问题,请随时通过support.braintreepayments.com 联系支持人员。我会首先尝试更新您的 Braintree Android SDK 版本。 Google Pay 在 v2.4.0 上不可用。自该版本以来有很多增强功能,因此我建议更新到最新版本(当前为 2.20.0)。
  • 我面临同样的问题,我正在实现这个库github.com/JadavChirag/react-native-GPay。它对我来说工作正常。它可以很好地构建生产和开发:)
  • 我仍然遇到同样的问题。你找到解决办法了吗?

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


【解决方案1】:

supportedMethods 下使用https://google.com/pay 而不是android-pay,以便通过付款请求API 使用Google Pay。

查看这两个示例以获取更多参考:official docssample from the Chrome team

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    • 2016-09-27
    • 2019-10-16
    • 1970-01-01
    • 2020-11-12
    相关资源
    最近更新 更多