Javascript PaymentResponse api是否有检查付款响应的方法?
因为我们可以检查支付api是否受支持的状态。使用窗口对象:Javascript PaymentResponse api是否有检查付款响应的方法?,javascript,payment-method,payment-request-api,Javascript,Payment Method,Payment Request Api,因为我们可以检查支付api是否受支持的状态。使用窗口对象: window.PaymentRequest 是否有办法在付款后仅使用窗口对象检查PaymentResponse的状态 我无法访问支付代码,我正在尝试仅使用窗口对象检查状态。您可以返回响应。看到这个了吗 // global const { PaymentRequest } = window; // Selectors const buttons = document.querySelectorAll('button'); // con
window.PaymentRequest
是否有办法在付款后仅使用窗口对象检查PaymentResponse的状态
我无法访问支付代码,我正在尝试仅使用窗口对象检查状态。您可以返回响应。看到这个了吗
// global
const { PaymentRequest } = window;
// Selectors
const buttons = document.querySelectorAll('button');
// config
const paymentMethods = [
{
supportedMethods: ['basic-card']
}
];
const paymentDetails = {
total: {
label: 'What you pay',
amount: {
currency: 'USD',
value: 10
}
}
};
const paymentRequest = PaymentRequest && new PaymentRequest(
paymentMethods,
paymentDetails
);
const addItemToCart = ({target}) => {
paymentRequest
.show()
.then(paymentResponse => {
return paymentResponse.complete().then(response => {
console.log(response)
});
})
.catch(reason => console.error(`Error occurred: ${reason}`));
};
buttons.forEach(button => button.addEventListener('click', addItemToCart));
这里有一个代码笔链接
我已经提到我没有访问代码的权限。我只想检查使用窗口对象,如果是这样的话,那就没有办法了。这是出于安全原因。我想这是有办法的,因为他们为paymentrequest提供支持,所以可能有办法只检查付款是否完成。这可能不会导致任何安全问题,但您需要访问代码才能做到这一点