Answer the question
In order to leave comments, you need to log in
What causes VALIDATION_ERROR "transactions.amount"?
Hello !
I ran into a very interesting bug at the time of Amount formation, I don’t understand why this happens, I use PayPal-PHP-SDK
Case No. 1
$amount = new Amount();
$amount->setTotal(1.99 );
$amount->setCurrency('GBP');
$service_price = PricesServicesObject::allParams()[$serviceName]["price"]; //Получаю цену в формате 1.99 или 5.99
$amount = new Amount();
$amount->setTotal($service_price );
$amount->setCurrency('GBP');
"name":"VALIDATION_ERROR","details":[{"field":"transactions.amount","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 and currency which is a valid ISO Currency Code"
Answer the question
In order to leave comments, you need to log in
There is no mysticism in programming. If the first case works and the second doesn't, then it means that $service_price is still not 1.99 or 5.99, or there is no existing currency code in currency, otherwise there would be no
"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 and currency which is a valid ISO Currency Code". Try to call like this:
Make sure that in the second case in "GBP" B and P are English letters.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question