Why did I get error 10413 “Transaction refused because of an invalid argument. See additional error messages for details. The totals of the cart item amounts do not match order amounts”?

Issue
PayPal returned API error code 10413 - Transaction refused because of an invalid argument. See additional error messages for details. The totals of the cart item amounts do not match order amounts.

Cause
The value of PAYMENTREQUEST_0_AMT doesn't equal the sum of the following:

  • PAYMENTREQUEST_0_ITEMAMT (required)
  • PAYMENTREQUEST_0_TAXAMT (optional)
  • PAYMENTREQUEST_0_SHIPPINGAMT (optional)
  • PAYMENTREQUEST_0_HANDLINGAMT (optional)
  • PAYMENTREQUEST_0_SHIPDISCAMT (optional)
  • PAYMENTREQUEST_0_INSURANCEAMT (optional)

Solution
To resolve this issue, check that the sum of the values equals the value of PAYMENTREQUEST_0_AMT.

Here is an example:
PAYMENTREQUEST_0_AMT=524.20                     // Total
PAYMENTREQUEST_0_ITEMAMT=458.00                 // item * quantity + other items * quantity = ITEMAMT
PAYMENTREQUEST_0_SHIPPINGAMT=20.00              // shipping total
PAYMENTREQUEST_0_TAXAMT=46.20                   // tax total
L_PAYMENTREQUEST_0_NAME0=Books
L_PAYMENTREQUEST_0_AMT0=154.00                  // 154.00 * 2 = 308.00
L_PAYMENTREQUEST_0_QTY0=2
L_PAYMENTREQUEST_0_NAME1=CDs
L_PAYMENTREQUEST_0_AMT1=50.00                   // 50.00 * 3 = 150.00
L_PAYMENTREQUEST_0_QTY1=3
                                308.00 + 150.00 =  458.00 (same as ITEMAMT)
                                          20.00 // shipping
                                          46.20 // tax
                                         524.20 // AMT