首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Android处理(getPaymentToken)之后,支付令牌变得没有定义。

在Android处理(getPaymentToken)之后,支付令牌变得没有定义。
EN

Stack Overflow用户
提问于 2018-12-19 14:05:24
回答 1查看 663关注 0票数 0

我提到过这个- https://github.com/naoufal/react-native-payments#readme

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

代码语言:javascript
复制
           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时,它会返回“”。

所得到的答复如下

{"serializedPaymentToken":"{\"error\":{\"message\":\"Record未找到\“},\”字段error\“:[]}”,“paymentToken”:{“错误”:{“消息”:“未找到记录”},"fieldErrors":[]},"serializedPaymenToken":"{\"error\":{\"message\":\"Record未找到\“},”字段错误“:[]}”,“paymenToken”:{“错误”:{“消息”:“未找到记录”},“fieldErrors”:[]}‘

因此,令牌变得没有定义。你能告诉我问题可能隐藏在哪里吗?我应该提到,我在一个真正的设备(使用实际的google帐户)和sandBox上尝试过这段代码,但在任何情况下都失败了。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-01-01 17:37:45

supportedMethods下使用supportedMethods,而不是使用android-pay,以便通过支付请求API利用Google。

请查看以下两个示例,以获得更多参考:官方文件Chrome团队的样品

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53852921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档