无法构造“ PaymentRequest”:迭代器getter不可调用

时间:2019-03-10 15:25:32

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

我正在关注关于新的PaymentRequest API的tutorial,但出现错误:

  

未捕获的TypeError:无法构造“ PaymentRequest”:迭代器   getter不可调用。       在startPayment((索引):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

0 个答案:

没有答案