devlock
devlock

Reputation: 989

PayPal Express error "The totals of the cart item amounts do not match order amounts"

There's quite a lot on SO and other forums regarding this error but I've not been able to find an answer that helped.

When I submit the following simplified request without tax amounts it works, but as soon as tax is added the error occurs. Here's the code:

pdItem[0] = new PaymentDetailsItemType()
{
    Name = "xyz",
    Amount = new BasicAmountType() { currencyID = CurrencyCodeType.USD, Value = "10.00" },
    Tax = new BasicAmountType() { currencyID = CurrencyCodeType.USD, Value = "2.00" },
    Quantity = "1"
};

PaymentDetailsType pdt = new PaymentDetailsType()
{
    OrderDescription = orderDescription,
    PaymentDetailsItem = pdItem,
    OrderTotal = new BasicAmountType() { currencyID = CurrencyCodeType.USD, Value = "10.00" },
    TaxTotal = new BasicAmountType() { currencyID = CurrencyCodeType.USD, Value = "2.00" }
};

I tried all the possible combinations of tax and (net) totals but they all fail. Leave the tax out in pdItem[0] and pdt and it works.

Is it a problem if I leave off the tax and just send the totals including tax? if so, what needs doing for it to work?

Upvotes: 3

Views: 358

Answers (1)

Richard Garside
Richard Garside

Reputation: 89160

In your example you need to include the ItemTotal and make sure you're including the order total with tax and delivery included.

  • ItemTotal = 10
  • TaxTotal = 2
  • OrderTotal = 12

However I would leave tax out to simplify things.

If you work out tax on each item and tax on the total order value seperatley then you are vulnerable to small rounding errors that put the two totals 1 cent away from each other.

You don't need to send the tax information to Paypal, so unless your customers absolutely require it I would leave the seperate tax info out and just send all totals including tax.

We've done this on our site and it simplified things, it stopped all these errors and everyone was happy.

Upvotes: 3

Related Questions