samedi 23 décembre 2017

Basic Payments API demo

I'm trying to get a basic Payments 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! Thanks.




Aucun commentaire:

Enregistrer un commentaire