<!DOCTYPE html>
<html>
    <head>
        <title>PesaPI API</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv='cache-control' content='no-cache'>
        <meta http-equiv='expires' content='0'>
        <meta http-equiv='pragma' content='no-cache'>

        <script src="https://pvp.proxyapi.co.ke/dist/jquery-3.4.1.min.js"></script>
        <script src="https://pvp.proxyapi.co.ke/dist/pvp.min.js"></script>

    </head>

    <body>
        <div id="pvp_checkout_button">
            <p>hello</p>
        </div>
        <script>
            // var amount = 0;
            // window.onload (){
            //     amount = prompt('enter deposit amount')
            // };
            // //if you wish to use the default button and bootstrap is not available for styling of button, call this method...
            pvp.loadExternal();

            //set up this function
            pvp.createRequest = function()
            {
                const requestId = Math.round(Math.random() * 1000000);	//change to your own parameters
                const callBackUrl = "https://www.appletraders.co.ke/pay/callback.php";	//change to your callback URL
                const timestamp = Math.round((new Date()).getTime() / 1000);
                const amount = prompt('enter desired amount')

                return {
                    request_id: requestId,
                    request_timestamp: timestamp,
                    callback_url: encodeURIComponent(callBackUrl),
                    api_key: "8202636419-q4pc5tb2yx3qm44fnoww",
                    origin: "https://appletraders.co.ke/pay/stkpush.php",
                    amount: amount,
                    callback: function(eventObject)
                    {
                        /**
                         * Prints out:
                         * {
                         *      StatusCode: 0,                    // or -1 on failure
                         *      StatusDescription: "Success",       //or other message on failure
                         *      MerchantRequestID: "12801-2646216-1",           //or null on failure
                         *      CheckoutRequestID: "ws_CO_040220202222099388"   //or null on failure
                         * }
                         */
                        console.log(eventObject);
                    }
                };
            };

            //either render the button...
            pvp.render("#pvp_checkout_button");

            //...or call this function when ready if using a custom button
            pvp.execute();

            //documentation and more details available at https://docs.proxyapi.co.ke/v1/#pvp
        </script>
    </body>
</html>