so I am trying to include payment API checkout on my order.html page, however, you must add a script in the head of HTML document. in the script, you must specify the subtotal amount as a number, but I need this value to be dynamic. the "stotal" is the subtotal amount. I need to set subtotal to whatever the "stotal" is. How I do this?
<head>
<script type="text/javascript">
function paymentApi() {
V.init({
apikey: "",
encryptionKey: "",
paymentRequest: {
currencyCode: "USD",
subtotal: "11.00"
}
});
</script>
</head>
<body>
<p id="sub-total">
<strong>Total</strong>: <span id="stotal"></span>
</p>
Just change subtotal to get the value from the html as follows
<script type="text/javascript">
function paymentApi(){
V.init( {
apikey: "",
encryptionKey: "",
paymentRequest:{
currencyCode: "USD",
subtotal: document.getElementById('stotal').innerText //Here
}
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With