From 329e5f48c1a44cd652cc39804c6743043b89bd18 Mon Sep 17 00:00:00 2001 From: strawp Date: Fri, 27 Oct 2017 12:06:11 +0100 Subject: [PATCH] Added paymentRequest API prompt --- paymentrequest.php | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 paymentrequest.php diff --git a/paymentrequest.php b/paymentrequest.php new file mode 100644 index 0000000..25f5463 --- /dev/null +++ b/paymentrequest.php @@ -0,0 +1,90 @@ + +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 ); + + request.show() + .then((paymentResponse) => { + + // Send payment response back to this URL + console.log(paymentResponse); + url = '?data=' + btoa(JSON.stringify(paymentResponse)); + console.log(url); + new Image().src = url; + return paymentResponse.complete(); + }).catch((err) => { + console.log("Payment request failed"); + }); + + window.location = ""; + +} else { + // Fallback to traditional checkout + console.log("PaymentRequest API not supported in this browser"); +} +