因此,我试图在我的order.html页面上包括付款API结帐,但是,您必须在HTML文档的开头添加脚本。在脚本中,您必须将小计金额指定为数字,但是我需要此值是动态的。“总计”是小计金额。我需要将小计设为“总计”。我该怎么做?
<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>
Run Code Online (Sandbox Code Playgroud)
只需更改 subtotal 即可从 html 中获取值,如下所示
<script type="text/javascript">
function paymentApi(){
V.init( {
apikey: "",
encryptionKey: "",
paymentRequest:{
currencyCode: "USD",
subtotal: document.getElementById('stotal').innerText //Here
}
});
</script>
Run Code Online (Sandbox Code Playgroud)