if(window.PaymentRequest) { // Use Payment Request API const supportedPaymentMethods = [ { supportedMethods: ['basic-card'] } ]; const paymentDetails = { total: { label: '', amount:{ currency: '', value: } } }; const options = {}; const request = new PaymentRequest( supportedPaymentMethods, paymentDetails, options ); promise = request.show() .then((paymentResponse) => { return paymentResponse.complete() .then(() => {; // Send payment response back to this URL url = '?data=' + btoa(JSON.stringify(paymentResponse)); i= new Image(); i.addEventListener('load', function(){ window.location = ''; alert("Payment received, thank you") },false); i.src = url; }); }).catch((err) => { console.log("Payment request failed"); }); } else { // Fallback to traditional checkout console.log("PaymentRequest API not supported in this browser"); }