我试图使用文档中的示例代码测试Web API。我可以成功调用该应用程序并生成任何错误,但我硬编码到脚本中的金额传递不正确。好像差了两位数。
一、 E$500换算为5美元
我尝试过使用文本字段的值以及在值中硬编码。每次结果相同。
当我单击web表单上的按钮时,我调用代码:
<script>
document.getElementById("do_square_payment_btn").onclick = function (e) {
e.preventDefault();
var amount = $('#payment_amount_mobile').val();
console.log("Amount being passed in on square button click " + amount);
var dataParameter = {
"amount_money": {
"amount" : '5000' ,
"currency_code" : "USD"
},
"callback_url" : "https://jaydien.ezservicetrax.com",
"client_id" : "sq0idp-CHLAPYt9s1L594ZZZysDSQ",
"version": "1.3",
"notes": "Computer Service",
"options" : {
"supported_tender_types" : ["CREDIT_CARD"]
}
};
console.log(amount);
console.log("Square button clicked");
console.log("square-commerce-v1://payment/create?data=" + encodeURIComponent(JSON.stringify(dataParameter)));
location.href = "square-commerce-v1://payment/create?data=" + encodeURIComponent(JSON.stringify(dataParameter));
};
</script>
我做错了什么?