Question

I'm having a problem using the classic PayPal NVP API. It's complaining about how the totals don't match up and I really can't spot why that is.

The NVP name-value pairs which are sent to Paypal
array(19) {
  ["METHOD"]=>
  string(18) "SetExpressCheckout"
  ["AMT"]=>
  string(5) "48.00"
  ["MAXAMT"]=>
  string(5) "48.00"
  ["RETURNURL"]=>
  string(40) "http://vikingchallenge/site/payPalReturn"
  ["CANCELURL"]=>
  string(40) "http://vikingchallenge/site/payPalCancel"
  ["REQCONFIRMSHIPPING"]=>
  string(1) "0"
  ["NOSHIPPING"]=>
  string(1) "1"
  ["LOCALECODE"]=>
  string(2) "GB"
  ["PAYMENTREQUEST_0_AMT"]=>
  string(5) "48.00"
  ["PAYMENTREQUEST_0_CURRENCYCODE"]=>
  string(3) "GBP"
  ["PAYMENTREQUEST_0_ITEMAMT"]=>
  string(2) "40"
  ["PAYMENTREQUEST_0_TAXAMT"]=>
  string(4) "8.00"
  ["PAYMENTREQUEST_0_DESC"]=>
  string(6) "Adults"
  ["PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD"]=>
  string(18) "InstantPaymentOnly"
  ["L_PAYMENTREQUEST_0_NAME0"]=>
  string(6) "Adults"
  ["L_PAYMENTREQUEST_0_DESC0"]=>
  string(6) "Adults"
  ["L_PAYMENTREQUEST_0_AMT0"]=>
  string(2) "20"
  ["L_PAYMENTREQUEST_0_QTY0"]=>
  string(1) "2"
  ["L_PAYMENTREQUEST_0_TAXAMT0"]=>
  string(4) "8.00"
}

The response from Paypal
array(9) {
  ["TIMESTAMP"]=>
  string(20) "2013-07-15T14:54:32Z"
  ["CORRELATIONID"]=>
  string(13) "f64e080a80db6"
  ["ACK"]=>
  string(7) "Failure"
  ["VERSION"]=>
  string(4) "92.0"
  ["BUILD"]=>
  string(7) "6868861"
  ["L_ERRORCODE0"]=>
  string(5) "10413"
  ["L_SHORTMESSAGE0"]=>
  string(94) "Transaction refused because of an invalid argument. See additional error messages for details."
  ["L_LONGMESSAGE0"]=>
  string(63) "The totals of the cart item amounts do not match order amounts."
  ["L_SEVERITYCODE0"]=>
  string(5) "Error"
}
Was it helpful?

Solution

Change L_PAYMENTREQUEST_0_TAXAMT0 to 4.00 since you have qty=2 of this line item.

METHOD=SetExpressCheckout
CANCELURL=http://vikingchallenge/site/payPalCancel
RETURNURL=http://vikingchallenge/site/payPalReturn
MAXAMT=48.00
REQCONFIRMSHIPPING=0
NOSHIPPING=1
LOCALECODE=GB
PAYMENTREQUEST_0_AMT=48.00
PAYMENTREQUEST_0_CURRENCYCODE=GBP
PAYMENTREQUEST_0_PAYMENTACTION=SALE
PAYMENTREQUEST_0_ITEMAMT=40
PAYMENTREQUEST_0_TAXAMT=8.00
PAYMENTREQUEST_0_DESC=Adults
PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD=InstantPaymentOnly
L_PAYMENTREQUEST_0_NAME0=Adults
L_PAYMENTREQUEST_0_DESC0=Adults
L_PAYMENTREQUEST_0_AMT0=20
L_PAYMENTREQUEST_0_TAXAMT0=4.00
L_PAYMENTREQUEST_0_QTY0=2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top