【问题标题】:Failed to construct 'PaymentRequest': Iterator getter is not callable无法构造“PaymentRequest”:迭代器 getter 不可调用
【发布时间】:2019-08-01 00:29:54
【问题描述】:

我正在关注 tutorial 关于新的 PaymentRequest API,但我收到错误消息:

未捕获的 TypeError:无法构造“PaymentRequest”:迭代器 getter 是不可调用的。 在 startPayment ((index):45)

function startPayment(){
  if (!window.PaymentRequest) {
    // PaymentRequest API is not available. Forwarding to
    // legacy form based experience.
    location.href = '/checkout';
    return;
  }

  const methods = {
    supportedMethods: "basic-card",
    data: {
      supportedNetworks: [
        'visa', 'mastercard', 'amex', 'discover',
        'diners', 'jcb', 'unionpay'
      ]
    },
  }
  const details = {
    total: {
      label: 'Tyle musisz zabulić',
      amount: { currency: 'PLN', value : '22.15' }
    },
    displayItems: [{
      label: 'Narkotyki',
      amount: { currency: 'PLN', value: '22.15' }
    }],
  }
  const options = {
    requestShipping: true,
    requestPayerEmail: true,
    requestPayerPhone: true,
    requestPayerName: true,
    shippingType: 'delivery'
  };
  const request = new PaymentRequest(methods, details, options) // this line fails
  request.show().then(response => {
    // [process payment]
    // send to a PSP etc.
    response.complete('success');
  });
}

这是什么意思,我该如何解决? MacOS Chrome 版本:72.0.3626.121 64bit

【问题讨论】:

    标签: google-chrome progressive-web-apps payment-request-api


    【解决方案1】:

    支付方式应该是一个数组:

      const methods = [
         {
          supportedMethods: "basic-card",
          data: {
            supportedNetworks: [
              'visa', 'mastercard', 'amex', 'discover',
              'diners', 'jcb', 'unionpay'
            ]
          },
        }
      ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-15
      • 2021-01-15
      • 1970-01-01
      • 1970-01-01
      • 2016-08-23
      • 1970-01-01
      相关资源
      最近更新 更多