howardowens
howardowens

Reputation: 49

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.

Upvotes: 3

Views: 2211

Answers (1)

howardowens
howardowens

Reputation: 49

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.

Upvotes: 1

Related Questions