广场销售点未读取正确的金额

时间:2017-12-03 02:40:37

标签: javascript html square square-connect

我正在尝试使用文档中的示例代码测试Web API。我可以成功地调用APP而产生任何错误,但是我难以编码到我的脚本中的金额并没有超过正确。它似乎是两位数。

I.E $ 500转换为$ 5

我尝试过使用文本字段的值以及值中的硬编码。每次都有相同的结果。

当我点击网络表单上的按钮时,我会调用代码:

 <!--- Square CC Processing --->
   <script>  
          document.getElementById("do_square_payment_btn").onclick = function (e) {

            e.preventDefault();

            var amount = $('#payment_amount_mobile').val();
            //var amountFixed = amount.toFixed(2);
            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", // Replace this value with your application's callback URL
                "client_id" : "sq0idp-CHLAPYt9s1L594ZZZysDSQ", // Replace this value with your application's ID
                "version": "1.3",
                "notes": "Computer Service",
                "options" : {
                "supported_tender_types" : ["CREDIT_CARD"] //,"CASH","OTHER","SQUARE_GIFT_CARD","CARD_ON_FILE"
                }
            };

            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));

            };  


          //window.location = "square-commerce-v1://payment/create?data=" + encodeURIComponent(JSON.stringify(dataParameter));

    </script>

我做错了什么?

1 个答案:

答案 0 :(得分:1)

它完全按照预期工作。每the documentation

  

请注意,您指定适用货币的最小面额金额。例如,美元金额以美分为单位。有关详细信息,请参阅Working with monetary amounts

因此,美元的500值代表5美元。

相关问题