Mauro Bilotti
Mauro Bilotti

Reputation: 6242

PayPal: 'Value too long (max length 10)' in payment amount

I'm currently working with a project that needs to realize payments using PayPal accounts in some african countries. I could develop a demo project which allows me to interact with the API thanks to the test accounts registered in https://developer.paypal.com/developer/. Making some test cases I tried to specify a very long amount (in U$S) in order to see how to handle the error thrown. So, taking a look at this exception I see the following trace:

{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].amount.details.subtotal","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"},{"field":"transactions[0].item_list.items[0].price","issue":"Value too long (max length 10)"},{"field":"transactions[0].amount.total","issue":"Value too long (max length 10)"},{"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"},{"field":"transactions[0].item_list.items[0].price","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"},{"field":"transactions[0].amount.details.subtotal","issue":"Value too long (max length 10)"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"12d1b9e203241"}

Seeing the documentation mentioned on the information_link I see this paragraph:

Value too long (max length 10)

Provide a value that is 10 characters or less.

It's important to say that I'm working with american dollars as currency (ISO CODE: USD), so, at this point i'm wondering: what about other currencies? As I said, my application will be working with african countries like Nigeria (i.e.) whose currency is Naira valuated to 0.005013 U.S. dollars for each one, which could make that 10 decimal places are not enough. Someone has this issue? Shall I am always limited to 10 decimal places no matter the currency?

(I can't realize a currency conversion!)

Upvotes: 0

Views: 807

Answers (1)

Jason Z
Jason Z

Reputation: 874

...so, at this point i'm wondering: what about other currencies?

The list of supported PayPal currencies for the REST API can be found here.

As I said, my application will be working with african countries like Nigeria (i.e.) whose currency is Naira valuated to 0.005013 U.S. dollars for each one, which could make that 10 decimal places are not enough. Someone has this issue?

Unfortunately, the Nigerian Naira currency is not currently supported by PayPal. If you do need to operate in USD, then you are limited to operating in amounts that have a maximum of 2 decimal places.

Shall I am always limited to 10 decimal places no matter the currency?

If you take a look at the error details, it clarifies this by saying "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".

So in total, the amount can be 10 characters, not decimal places. For example, "1234567.90" is valid, where the decimal is included in the character count. This maximum character count aligns with the maximum PayPal transaction limit for supported currencies outlined here.

Upvotes: 3

Related Questions