【问题标题】:error using react native /react-native-payments-alive library to do apple pay使用 react native /react-native-payments-alive 库做苹果支付时出错
【发布时间】:2020-11-04 17:54:54
【问题描述】:

希望有人可以帮助使用 react-native-payments-alive。

我有以下代码

import {PaymentRequest} from 'react-native-payments-alive';
const METHOD_DATA = [{
        supportedMethods: ['apple-pay'],
        data: {
          merchantIdentifier: 'merchant.uat.com',
          supportedNetworks: ['visa', 'mastercard'],
          countryCode: 'USA',
          currencyCode: 'USD'
        }
      }];
const DETAILS = {
        id: 'simple-basket',
        displayItems: [
          {amount: "369.00", label: "Product 1 "},
          {amount: "10.00", label: "Shipping"}
        ],
        total: {
          label: 'Grand Total',
          amount: {currency: 'USD', value: '379.00'}
        }
      };

const paymentRequest = new PaymentRequest(METHOD_DATA, DETAILS);

paymentRequest.show()
              .then(paymentResponse => {
                console.log('paymentResponse ', paymentResponse)
                paymentResponse.complete('success');
              }).catch((error) => console.log(error));

我不断收到此错误

未能构造“PaymentRequest”:所需的成员值未定义。

任何帮助表示赞赏?

【问题讨论】:

    标签: react-native applepay


    【解决方案1】:

    我知道这很旧,但他们改变了您发送数据的方式,并且没有在 react-native-payments 的文档上更新,通过他们的代码,

    const DETAILS = {
        id: 'simple-basket',
        displayItems: [
          {amount: { value: "369.00", currency: "USD" } , label: "Product 1 "},
          {amount: { value: "10.00", currency: "USD" }, label: "Shipping"}
        ],
        total: {
          label: 'Grand Total',
          amount: {currency: 'USD', value: '379.00'}
        }
      };
    

    应该适合你

    【讨论】:

      猜你喜欢
      • 2018-03-05
      • 1970-01-01
      • 1970-01-01
      • 2020-09-26
      • 2019-03-30
      • 2018-04-19
      • 2020-07-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多