EXPECTED_INTEGER — Issues with Square payment portal

后端 未结 2 911
借酒劲吻你
借酒劲吻你 2021-01-21 17:16

I\'m having issues accepting payment through my ecommerce site. This only seems to happen randomly, I\'ve accepted payment previous without issue but every so often this happens

相关标签:
2条回答
  • 2021-01-21 17:38

    This error occurs whenever you try to charge with an amount that is not an integer value, such as a decimal or a floating point number. One thing you can do to prevent this is to check and make sure the type of amount you're charging is a whole number.

    Additionally, thank you for the feedback about Square's Developer Doc. We are constantly improving the product based on feedback like this, so I’ll be sure to share your thoughts with the appropriate team.

    0 讨论(0)
  • 2021-01-21 17:58

    I had a similar problem. The numbers that were being passed by my input field were being read as strings instead of integers. Even though the output in the front end console read like an integer, I noticed on the backend the numbers coming back form req.body had quotes around them. The fix was to use parseInt to strip the quotes away. My code is based on Node/Express on the backend and Handlebars on the frontend. I hope this example helps:

    //the name chargeAmount is passed to the server holding contain the value of the input
    
    <input name="chargeAmount">
    
    // on the backend req.body is set to a variable and then that variable
    // is passed to another variable and parsed where the foo object contains
    // the amount I want to charge.  The parseInt() method insures that the " "
    // are removed from the string and allows the integer to be passed into the 
    // object.  When you're running your tests, make sure that the integer does
    // not have quotes around it.  If it does, then the back end reads that data
    // as a string and not an integer
    
    var foo = req.body;
    var bar = parseInt(foo.chargeAmount) 
    var request_body = {
            card_nonce: foo.nonce,
            amount_money: {
                amount: bar, 
                currency: 'USD'
            },
    
    0 讨论(0)
提交回复
热议问题