付款请求API:什么是收款人帐户?

时间:2017-05-13 16:03:42

标签: payment-processing android-pay payment-request-api

我正在查看付款请求API,这显然在某些浏览器上可用,但我想知道,您在哪里/如何设置付款发送到的帐户?我在下面的代码中看不到任何地方指定了一个帐户,该帐户将在成功时发送付款:

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

  // Supported payment methods
  var supportedInstruments = [{
      supportedMethods: ['basic-card']
      data: {
        supportedNetworks: [
          'visa', 'mastercard', 'amex', 'discover',
          'diners', 'jcb', 'unionpay'
        ]
      }
  }];

  // Checkout details
  var details = {
    displayItems: [{
      label: 'Original donation amount',
      amount: { currency: 'USD', value: '65.00' }
    }, {
      label: 'Friends and family discount',
      amount: { currency: 'USD', value: '-10.00' }
    }],
    total: {
      label: 'Total due',
      amount: { currency: 'USD', value : '55.00' }
    }
  };

  // 1. Create a `PaymentRequest` instance
  var request = new PaymentRequest(supportedInstruments, details);

  // 2. Show the native UI with `.show()`
  request.show()
  // 3. Process the payment
  .then(result => {
    // POST the payment information to the server
    return fetch('/pay', {
      method: 'POST',
      credentials: 'include',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(result.toJSON())
    }).then(response => {
      // 4. Display payment results
      if (response.status === 200) {
        // Payment successful
        return result.complete('success');
      } else {
        // Payment failure
        return result.complete('fail');
      }
    }).catch(() => {
      return result.complete('fail');
    });
  });
}

document.querySelector('#start').addEventListener('click', onBuyClicked);

参考。 https://developers.google.com/web/fundamentals/discovery-and-monetization/payment-request/deep-dive-into-payment-request

参考。 https://www.w3.org/TR/payment-request/

1 个答案:

答案 0 :(得分:2)

长话短说:你没有。

付款请求API 是付款处理者的替代品。浏览器本身无法处理资金转帐到您的帐户 - 它甚至无法验证所提供的付款方式是否有效(尽管Android Pay可以执行此操作)。

Per Introducing the Payment Request API doc(强调我的):

  

...

     

然后,浏览器将付款UI呈现给用户,用户选择a   付款方式并授权交易。付款方式可以是   像信用卡一样简单,已经存储了   浏览器,或作为第三方应用程序编写的深奥   专门为网站付款(此功能是   快来了)。用户授权交易后,全部   必要的付款详细信息将直接发送回网站。对于   例如,对于信用卡付款,该网站将获得一张卡   号码,持卡人姓名,到期日期和CVC

     

...

换句话说,付款请求API只是一种更简单,更安全的方式来收集用户的卡号和处理付款所需的其他信息。收到此信息后,与用户通过普通表单提交信息几乎相同。您仍然需要支付处理器(或类似的东西)来实际创建交易。

相关问题