3

This is what i've sent to paypal using nvp and express_checkout, but it gives me error do not match order amount, can you help me please which one i'm missing or calculated wrongly?

I have read post with same problem, but still got no clue how to fixed mine out from their suggested answers. Thank you in advance.

Array
(
    [METHOD] => SetExpressCheckout
    [SOLUTIONTYPE] => Sole
    [LANDINGPAGE] => Billing
    [ALLOWNOTE] => 0
    [PAYMENTREQUEST_0_PAYMENTACTION] => Sale
    [PAYMENTREQUEST_0_AMT] => 70.00
    [PAYMENTREQUEST_0_CURRENCYCODE] => AUD
    [PAYMENTREQUEST_0_INVNUM] => 124-1440383961
    [RETURNURL] => http://mysite.here/checkout/124/payment/return/I2Ir45QRcKkACL__OFbNrNjc8cL9Iajr0UU1LzXesWA
    [CANCELURL] => http://mysite.here/checkout/124/payment/back/I2Ir45QRcKkACL__OFbNrNjc8cL9Iajr0UU1LzXesWA
    [L_PAYMENTREQUEST_0_NAME0] => Babbling Brook - 7min Loop
    [L_PAYMENTREQUEST_0_AMT0] => 35.00
    [L_PAYMENTREQUEST_0_QTY0] => 1
    [L_PAYMENTREQUEST_0_NUMBER0] => babblingbrook-7minloop
    [L_PAYMENTREQUEST_0_NAME1] => Crackling Fire - 7min Loop
    [L_PAYMENTREQUEST_0_AMT1] => 35.00
    [L_PAYMENTREQUEST_0_QTY1] => 1
    [L_PAYMENTREQUEST_0_NUMBER1] => cracklingfire-7minloop
    [PAYMENTREQUEST_0_ITEMAMT] => 63.64
    [PAYMENTREQUEST_0_TAXAMT] => 6.36
    [NOSHIPPING] => 1
    [USER] => myusernamehere
    [PWD] => ANDPASSWORDHERE
    [SIGNATURE] => A.bIs5s0FCBv.KdshBEZ.0y1BshsBr9
    [VERSION] => 76.0
)

PayPal server response:

Array
(
    [TIMESTAMP] => 2015-08-24T02:20:54Z
    [CORRELATIONID] => 7b10ddf49b4c1
    [ACK] => Failure
    [VERSION] => 76.0
    [BUILD] => 000000
    [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
)
axscode
  • 123
  • 8

1 Answers1

3

The last time I played with this I was using API version 113 (which is over a year old now).

I think you've just really only missed the per-item tax amount.

The PAYMENTREQUEST_0_ITEMAMT field should be equal to the sum of each item's amount (L_PAYMENTREQUEST_0_AMTn) exclusive of tax, multiplied by the quantity. So you should have

'L_PAYMENTREQUEST_0_AMT0' => 31.82,
'L_PAYMENTREQUEST_0_AMT1' => 31.82,
'PAYMENTREQUEST_0_ITEMAMT' => 63.64

PAYMENTREQUEST_0_TAXAMT is the sum of each item's tax amount (L_PAYMENTREQUEST_0_TAXAMTn) multiplied by the quantity. You haven't specified the item tax amount but let's say it's something like

'L_PAYMENTREQUEST_0_TAXAMT0' => 3.18,
'L_PAYMENTREQUEST_0_TAXAMT1' => 3.18,
'PAYMENTREQUEST_0_TAXAMT' => 6.36

Finally, PAYMENTREQUEST_0_AMT is the sum of PAYMENTREQUEST_0_ITEMAMT and PAYMENTREQUEST_0_TAXAMT plus any shipping

'PAYMENTREQUEST_0_AMT' => 70.00
Phil
  • 157,677
  • 23
  • 242
  • 245
  • Thanks @Phil, i'll checkout my calculation, i thought it's ok to TAX on total and not need on item. – axscode Aug 24 '15 at 04:27
  • @axscode it could be. I was just looking at my old code and that's how I've got it which passes my integration tests. You're welcome to have a look at it if you like – Phil Aug 24 '15 at 04:46
  • But it works with your solution! Thank you very much. Phil++++, just wondering though, is it possible to change TAX label to GST in paypal? – axscode Aug 24 '15 at 04:55
  • @axscode If you were to omit the per-item tax, you'd still need to follow the calculation rules I've outlined which means your total amount should be 76.36 (or change your item amounts to the ex-GST amount). I'm not sure about the labels. I feel like it may be possible via the PayPal seller customisation however I've never bothered – Phil Aug 24 '15 at 04:58
  • Thanks a Lot this saves my day. :D – axscode Aug 24 '15 at 05:05
  • Hi, Phil I didn't know if anything changed with the API version but as of API version 204, for item amt and item tax, you don't have to multiply them with the item qty. Otherwise, I get an error. But for the older APis, this definitely works. :) – Annie Lagang Sep 15 '16 at 02:06