PayPal problems

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Pejka
Posts: 17
Joined: 24 Oct 2016, 11:04

PayPal problems

Post by Pejka » 10 Nov 2016, 12:35

Hello!
I can't get the PayPal Express payment method to work properly. It seems to be configured correctly, but, by default it throws the following error:

Code: Select all

PayPal Express: method = Aimeos\MShop\Service\Provider\Payment\PayPalExpress::process, order ID = 51, response = Array
(
    [TIMESTAMP] => 2016-11-10T09:23:42Z
    [CORRELATIONID] => be189898ab422
    [ACK] => Failure
    [VERSION] => 87.0
    [BUILD] => 26899334
    [L_ERRORCODE0] => 11832
    [L_ERRORCODE1] => 11832
    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_SHORTMESSAGE1] => Maximum amount of order is less than itemized amounts.
    [L_LONGMESSAGE0] => Maximum amount of order is less than itemized amounts.
    [L_LONGMESSAGE1] => Maximum amount of order is less than itemized amounts.
    [L_SEVERITYCODE0] => Error
    [L_SEVERITYCODE1] => Error
)
After a bit of searching, I tried increasing the MAXAMT to a ridiculous amount, after which I get the following:

Code: Select all

ACK=Failure&L_ERRORCODE0=81002&L_SHORTMESSAGE0=Unspecified%20Method&L_LONGMESSAGE0=Method%20Specified%20is%20not%20Supported&L_SEVERITYCODE0=Error
Googling the 81002 error code reveals it to be some very vague error, with seemingly several solutions, none if which seem to work.
What could be causing this? Changing MAXAMT shouldn't interfere with the METHOD setting, so I'm really in the dark about what's happening here.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: PayPal problems

Post by aimeos » 10 Nov 2016, 23:56

Can you add a debug statement here: https://github.com/aimeos/aimeos-core/b ... rl.php#L32
Something like

Code: Select all

error_log( print_r( $payload, true ) );
Maybe the output can shed some light on what might be the problem.
Another option is that you try the Omnipay PayPal driver using the ai-payment extension.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Pejka
Posts: 17
Joined: 24 Oct 2016, 11:04

Re: PayPal problems

Post by Pejka » 11 Nov 2016, 09:03

Using dd( print_r( $payload, true ) ), I got the following:

Code: Select all

"VERSION=87.0
&SIGNATURE=THISISSECRET
&USER=info-facilitator_api1.quadprogroup.com
&PWD=ALSOSECRET
&L_PAYMENTREQUEST_0_NUMBER0=155
&L_PAYMENTREQUEST_0_NAME0=Granite
&L_PAYMENTREQUEST_0_QTY0=1
&L_PAYMENTREQUEST_0_AMT0=29990.00
&L_SHIPPINGOPTIONAMOUNT0=0.00
&L_SHIPPINGOPTIONLABEL0=Personal+pickup
&L_SHIPPINGOPTIONNAME0=self_pickup
&L_SHIPPINGOPTIONISDEFAULT0=true
&MAXAMT=1000000000
&PAYMENTREQUEST_0_AMT=29990.00
&PAYMENTREQUEST_0_ITEMAMT=29990.00
&PAYMENTREQUEST_0_SHIPPINGAMT=0.00
&PAYMENTREQUEST_0_INSURANCEAMT=0.00
&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false
&PAYMENTREQUEST_0_SHIPDISCAMT=0.00
&PAYMENTREQUEST_0_CURRENCYCODE=HUF
&PAYMENTREQUEST_0_PAYMENTACTION=sale
&METHOD=SetExpressCheckout
&PAYMENTREQUEST_0_INVNUM=74
&RETURNURL=http%3A%2F%2Ffdg.quadprogroup.com%2Fhu%2Fshop%2Fconfirm%3Fcode%3Dpaypal%26orderid%3D74%26currency%3DHUF
&CANCELURL=http%3A%2F%2Ffdg.quadprogroup.com%2Fhu%2Fshop%2Fconfirm%3Fcode%3Dpaypal%26orderid%3D74%26currency%3DHUF"

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: PayPal problems

Post by aimeos » 11 Nov 2016, 10:44

Can you set MAXAMT==29990.01 or MAXAMT==29991.00 for testing?
The code adds 0.01 to the amount but it seems that after the floating point calculation it's rounded to 29990.00 again instead of 29990.01. The MAXAMT value must be slightly bigger than the real value because PayPal can't calculate and produces rounding errors themselves.

If setting the MAXAMT value to one of the above works, you can try to change the calculation to:

Code: Select all

$amt = (string) $amount * 100 + 1;
$values['MAXAMT'] = substr( $amt, 0, -2 ) . '.' . substr( $amt, -2 );
or

Code: Select all

$values['MAXAMT'] = bcadd( $amount, '0.01', 2 ); // requires bcmath extension
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Pejka
Posts: 17
Joined: 24 Oct 2016, 11:04

Re: PayPal problems

Post by Pejka » 14 Nov 2016, 08:38

Still the same:

Code: Select all

PayPal Express: method = Aimeos\MShop\Service\Provider\Payment\PayPalExpress::process, order ID = 80, response = Array
(
    [TIMESTAMP] => 2016-11-14T08:35:27Z
    [CORRELATIONID] => dc88e5d57e161
    [ACK] => Failure
    [VERSION] => 87.0
    [BUILD] => 26966222
    [L_ERRORCODE0] => 11832
    [L_ERRORCODE1] => 11832
    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_SHORTMESSAGE1] => Maximum amount of order is less than itemized amounts.
    [L_LONGMESSAGE0] => Maximum amount of order is less than itemized amounts.
    [L_LONGMESSAGE1] => Maximum amount of order is less than itemized amounts.
    [L_SEVERITYCODE0] => Error
    [L_SEVERITYCODE1] => Error
)

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: PayPal problems

Post by aimeos » 14 Nov 2016, 10:58

What have been the request parameters?

You can also try the PayPal driver of the Omnipay library by using the ai-payments (resp. aimeos_pay) extension. It doesn't send item prices to PayPal so it might be not affected by this problem.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Pejka
Posts: 17
Joined: 24 Oct 2016, 11:04

Re: PayPal problems

Post by Pejka » 14 Nov 2016, 16:24

Thanks, will try it out!

Post Reply