Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal API: The totals of the cart item amounts do not match order amounts

Tags:

php

api

paypal

There are a lot of posts about this error, but they all not apply on me. I really don't understand why the amounts wouldn't match. I have ITEMAMT which matches AMT0 * QTY0. And AMT matches ITEMAMT + SHIPPINGAMT. I checked the docs over and over and it really should work this way. It works when I totally remove the shipping out of it...

The AMT in the checkout url is 73.9 too.

I really hope someone is familiar with this very confusing error, and knows what I am doing wrong...

Thanks in advance

Array
(
    [TIMESTAMP] => 2013-01-24T22:56:09Z
    [CORRELATIONID] =>
    [ACK] => Failure
    [VERSION] => 62.0
    [BUILD] => 4181146
    [L_ERRORCODE0] => 10413
    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_LONGMESSAGE0] => The totals of the cart item amounts do not match order amounts.
    [L_SEVERITYCODE0] => Error
)
Array
(
    [PAYMENTREQUEST_0_PAYMENTACTION] => Sale
    [L_PAYMENTREQUEST_0_NAME0] => XXXX
    [L_PAYMENTREQUEST_0_NUMBER0] => 30533
    [L_PAYMENTREQUEST_0_DESC0] => XXXX
    [L_PAYMENTREQUEST_0_AMT0] => 30.95
    [L_PAYMENTREQUEST_0_QTY0] => 2
    [PAYMENTREQUEST_0_ITEMAMT] => 61.9
    [PAYMENTREQUEST_0_TAXAMT] => 0
    [PAYMENTREQUEST_0_SHIPPINGAMT] => 12
    [PAYMENTREQUEST_0_INSURANCEAMT] => 0
    [PAYMENTREQUEST_0_AMT] => 73.9
    [PAYMENTREQUEST_0_CURRENCYCODE] => USD
    [REQCONFIRMSHIPPING] => 1
    [PAYMENTREQUEST_0_SHIPTOSTREET] => XXXX
    [PAYMENTREQUEST_0_SHIPTOCITY] => XXXX
    [PAYMENTREQUEST_0_SHIPTOSTATE] => XX
    [PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE] => XX
    [PAYMENTREQUEST_0_SHIPTOZIP] => XXXXXX
    [PAYMENTREQUEST_0_SHIPTOPHONENUM] => XXXXXXXX
)
like image 377
Chris Avatar asked Jan 24 '13 23:01

Chris


1 Answers

It is mandatory that you send currency with 2 decimal places. It appears that you are only providing 1.

$amt = 61.9;
$amt = sprintf("%.2f",$amt); // 61.90

Paypal will return this error because the amount is not in the correct format:

Take a look at Table A.2 under the AMT row:

http://www.paypalobjects.com/en_US/ebook/PP_NVPAPI_DeveloperGuide/Appx_fieldreference.html

This rule should apply every time you set a 'money' parameter.

like image 187
Samuel Cook Avatar answered Oct 12 '22 09:10

Samuel Cook