Page 1 of 2

PayPal Error :: Transaction refused bc of invalid argument

Posted: 16 Feb 2017, 14:47
by Nils
Hi :)

I'm testing buying with PayPal. I created a sandbox account for that. When I click on "Buy" I get an error (from the log):

PayPal Express: method = Aimeos\MShop\Service\Provider\Payment\PayPalExpress::process, order ID = 17, response = Array
(
[TIMESTAMP] => 2017-02-16T13:28:36Z
[CORRELATIONID] => b7e229de22fca
[ACK] => Failure
[VERSION] => 87.0
[BUILD] => 30029726
[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
)

In the basket is 1 product with a quantity of 1.


I added a debug statement here: https://github.com/aimeos/aimeos-core/b ... rl.php#L32

Output (I replaced some information with "XXX"):

"VERSION=87.0&SIGNATURE=XXX&USER=XXX&PWD=XXX&L_PAYMENTREQUEST_0_NUMBER0=17&L_PAYMENTREQUEST_0_NAME0=XXX&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_AMT0=47.12&L_SHIPPINGOPTIONAMOUNT0=5.46&L_SHIPPINGOPTIONLABEL0=Standard&L_SHIPPINGOPTIONNAME0=default&L_SHIPPINGOPTIONISDEFAULT0=true&MAXAMT=53.63&PAYMENTREQUEST_0_AMT=53.62&PAYMENTREQUEST_0_ITEMAMT=48.16&PAYMENTREQUEST_0_SHIPPINGAMT=5.46&PAYMENTREQUEST_0_INSURANCEAMT=0.00&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_SHIPDISCAMT=0.00&PAYMENTREQUEST_0_CURRENCYCODE=EUR&PAYMENTREQUEST_0_PAYMENTACTION=sale&METHOD=SetExpressCheckout&PAYMENTREQUEST_0_INVNUM=16&RETURNURL=XXX&CANCELURL=XXX"


I use the demo service provider for PayPal with the following configuration:

paypalexpress.AccountEmail -> XXX
paypalexpress.ApiUsername -> XXX
paypalexpress.ApiPassword -> XXX
paypalexpress.ApiSignature -> XXX
paypalexpress.PaypalUrl -> https://www.sandbox.paypal.com/webscr&c ... token=%1$s
paypalexpress.ApiEndpoint -> https://api-3t.sandbox.paypal.com/nvp


What could be the problem?


Setup: Typo3 7.6.11, Aimeos 16.10.3 (I tried updating to 17.1.0 and 17.2.0, but got an error)

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 16 Feb 2017, 22:04
by aimeos
There is a difference in the sum between the single line and the total value:
L_PAYMENTREQUEST_0_AMT0=47.12
L_SHIPPINGOPTIONAMOUNT0=5.46

The sum is 52.58 but the total amount is:
PAYMENTREQUEST_0_AMT=53.62

So there's a difference of 1.04. Do you use costs per product or something special?

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 20 Feb 2017, 09:55
by Nils
Yes, I use deliberately costs per product. And I have one manual delivery service that adds nothing to the amount.

In the PayPal service I have :

Price: 0.00
Rebate: 0.00
Costs: 0.00
Tax Rate: 20.00

I forgot to say that it is a b2b shop (sorry), so I set taxflag to 0.

The basket shows:

sub total 39.60 €
delivery 5.46 €
+ 19.00% MwSt. 8.56 €
total 53.62 €
quantity 1 Artikel

I just see, the difference of 1.04 you talk about seems to result from applying the tax rate to the delivery costs:
5.46 * 0.19 = 1.0374

What I noticed in the debug output I posted earlier:

MAXAMT=53.63&PAYMENTREQUEST_0_AMT=53.62

Supposed the two parameters refer to the same thing, there is a difference of 1 cent. If that's the case, could it be some sort of rounding error like rounding 1.0374 to 1.03 instead of 1.04?

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 20 Feb 2017, 14:26
by aimeos
The 1 cent different between MAXAMT and PAYMENTREQUEST_0_AMT is intended because PayPal can't round correctly ;-)

The problem is the tax for the shipping costs. Did you set the tax rate of the price item for the delivery service to 19%?

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 20 Feb 2017, 15:09
by Nils
The delivery service doesn't cause any additional costs, it's just a dummy (my understanding is that I need at least one delivery service).

Price, rebate, costs and tax rate of the price item for the delivery service are all set to 0.00.

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 20 Feb 2017, 15:16
by aimeos
OK, then your bought product must have a "costs per item" value greater than 0.00
Is this the case?

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 20 Feb 2017, 15:36
by Nils
Yes, correct.

The basket shows:

sub total 39.60 €
delivery 5.46 €
+ 19.00% MwSt. 8.56 €
total 53.62 €
quantity 1 Artikel

The "costs per item" are those 5.46 €.

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 20 Feb 2017, 17:13
by aimeos
The problem was that the Aimeos PayPal service provider mixed up values with different tax rates (5.46/19 and 0.00/0.00). This resulted in a wrong value that's handed over to PayPal and when PayPal sums up the values, they didn't match.

Can you try this test release?
https://aimeos.org/fileadmin/download/a ... 1-pre2.zip

You've said you tried to update to 17.2.0 before. Please remove the mshop_stock and mshop_stock_type tables if they exist before updating.

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 21 Feb 2017, 10:14
by Nils
There are no mshop_stock and mshop_stock_type tables. But the error message I got mentioned mshop_product_stock.

Do you mean mshop_stock -> mshop_product_stock? What about mshop_stock_type -> ?

Re: PayPal Error :: Transaction refused bc of invalid argume

Posted: 21 Feb 2017, 10:16
by aimeos
Can you please post the error and the stack trace?