Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal error "Currency amount must be non-negative number"

I'm trying to implement the CFC (coldfusion) code found here:

http://www.sitekickr.com/blog/integrating-paypal-payflow-pro-rest-api/

I'm still at the testing stage and haven't even tried passing my own variables, just using the CFSET example provided.

<cfset response = paypal.capture( card_type = "visa"
      , card_number = "4556747948786484"
      , card_exp_month = "12"
      , card_exp_year = "2018"
      , card_firstname = "Bob"
      , card_lastname = "Smith"
      , amount = 15.25
      , description = "Order 1011"
 )> 

I'm getting this error:

{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].amount.total","issue":"Currency amount must be non-negative number, may optionally contain exactly 2 decimal places separated by '.', optional thousands separator ',', limited to 7 digits before the decimal point"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"dfb7b0588d38e"}

It makes no sense because the currency value I'm passing is NOT a negative and contains only two decimal places. There is no obvious error with the "amount" value I'm passing.

So I'm stuck.

like image 874
howardowens Avatar asked Feb 01 '26 11:02

howardowens


1 Answers

Here's how I solved my problem.

I discovered that in my PayPal developer account, I could go to the menu Sandbox/Transactions and get more details on transaction attempts.

Through this, I discovered the value I was actually passing for total was "15.25|||"

PayPal was receiving: "total": "15.25|||"

Upon further investigation, at line 57 of the CFC, I found

"total"= (NumberFormat(arguments.amount, "9.99")) & "|||",

I removed the: & "|||"

And got a successful response from PayPal's sandbox.

like image 125
howardowens Avatar answered Feb 03 '26 09:02

howardowens