I'm trying to get a basic Web Payments Request API demo to work. As far as I understand, a pop up should show, asking which credit card I would like to use, when I run this code:
<html>
<head>
</head>
<body>
<h1>Pay here</h1>
<script>
if(window.PaymentRequest){
alert("Payment request exists!");
const supportedPaymentMethods = [ {
supportedMethods: ["basic-card"]
}
];
const paymentDetails = {
total: {
label: "Total Cost",
amount: {
currency: "GBP",
value: 1
}
}
};
const options = {};
const paymentRequest = new PaymentRequest(
supportedMethods, paymentDetails, options
);
paymentRequest.show();
}
</script>
</body>
</html>
But not much happens. What does happen is that the alert message shows up. I'm just trying to get the basics working. I don't believe this code will send money to anyone because no account is mentioned. I hope to make the next step. Please help!
I've finally found a working demo. It saves your credit card details in the browser and displays it in an easy to use format (without form fields). It does not send the credit card details to the payment system, it just prepares it:
You can copy/paste the code above and save as HTML and load it from your local drive (no need for any fancy stuff like loading it from a secure https URL like I thought).