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



我正在查看付款请求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/

长话短说:你没有。

付款请求 API不能替代付款处理器。浏览器本身无法处理资金转入您的帐户 - 它甚至无法验证提供的付款方式是否有效(尽管Android Pay可以做到这一点)。

根据介绍付款请求 API 文档(强调我的):

然后,浏览器向用户显示付款 UI,用户选择 付款方式并授权交易。付款方式可以是 就像已经由 浏览器,或像第三方编写的应用程序一样深奥 专门用于向网站付款(此功能是 即将推出)。用户授权交易后,所有 必要的付款详细信息将直接发送回网站。为 例如,对于信用卡付款,网站将取回一张卡 编号、持卡人姓名、到期日期和 CVC

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

最新更新