magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Paypal Express Checkout not working #14949

Closed chequille closed 6 years ago

chequille commented 6 years ago

Sorry Arjen, I know, that I have to use the guidlines, but must be honest, that I am little bit angry because things did work and with update or with the migration from 1.9.x thinks do not work anymore.

Preconditions Magento 2.2.4 PHP 7.0.29 Linux Server (Nginx and Apache) Migration-Tool

Steps to reproduce Developer Mode PayPal correctly configured in SANDBOX Mode Migration from 1.9.3.4 of customers and products Checkout with Paypal as payment

Expected result Order should be placed and Paypal site should ask for user and password

Actual result Getting Message "Express Checkout was cannceled"

Best regards, Jürgen

ArjenMiedema commented 6 years ago

Can you please use the issue reporting guidelines? I could look into this, but it's hard to find the exact issue you're facing without any additional information like steps to reproduce.

Thanks!

chequille commented 6 years ago

Hi Arjen, maybe something to find the solution for this problem. I made two short video clips. You will sse in the video "paypalnotworking.mp4", that when I press the button for placing the order"zahlungspflichtig bestellen", another window is opening and tries to access to paypal. This is not working and results in the cancelation of the checkout with paypal. In the second video, I close this window and are clicking on "click to continue" and in this case, paypal site is coming and I can accept payment and the order will be placed.

Maybe with this, you have an idea what is wrong. Maybe some timing issues? BR Chequille

paypalvideos.zip

gwharton commented 6 years ago

Hi @chequille Are you running any third party modules, particularly any one step checkout type modules.

chequille commented 6 years ago

Hi @gwharton, I am running some own and third party modules, but none of them change the checkout process. It is the original from the core. They are mainly backend oriented, generating PDF invoices and add pdf to email and stuff like this. But what I can do is to disable all of them and see if there is any change. BR Chequille

gwharton commented 6 years ago

I saw the same issue this week on my test setup, but it started after updating one of my third party modules. Ill check tomorrow on a fresh install to see if i can reproduce it.

chequille commented 6 years ago

Hi @gwharton, so, I disabled every single module which was installed. But no change, still the same behaviour as in my videos.

BR Chequille

Cristiano81 commented 6 years ago

Hello, same issue here, with fresh installation of Magento 2.2.4 CE. Sometimes it works, sometimes not. Here you can take a look at payment.log , in not working log it seems that the process stops after SetExpressCheckout.

payment_not_working.log payment_working.log

joni-jones commented 6 years ago

Hi, @chequille, we also faced the same issue. Seems, PayPal Express made some changes in their API, we have such issue in different Magento versions.

chequille commented 6 years ago

Hi @gwharton, if joni-jones is right, the fix will be available soon or? :-)

BR Chequille

gwharton commented 6 years ago

Hi Chequille. It seems quite significant if it is an issue with a change to the API, so hopefully someone will pick this one up and look at it quite soon. Unfortunately I have neither the skills nor the time to delve into the paypal module.

chequille commented 6 years ago

Ok, but who is responsible at the Magento team to look into this. Magento team is providing a software which ist not working. Even if it is open source somebody should should take a look into it. I am even not 100% sure if it is really a change in the API from PAYPAL because if it would be the case, why is my 1.9.3.x version still working. Ok, it is not sandbox mode, but as far as I know it is the same API or? Hopefully somebody has the time to solve this. BR Chequille

gwharton commented 6 years ago

This one might be different as its pretty core and pretty fundamental to the working of Magento in a lot of installations, but in my experience, the quickest way of getting a bug looked at is (if you have the skills) to attempt to diagnose the problem as much as you can yourself. Telling the Magento team "it doesn't work..... fix it" is unlikely to get anyone jumping at the issue, but if you can find detailed logs, provide exact details (step by step) to reproduce the bug on a fresh install of 2.2.4, even delve into the code and hack a bit on a test installation with a bit of printf/logger->debug() testing to get as close to the root cause as you can, will help.

If you can present the issue like "Here is exactly what is wrong, its this exact part of the API thats changed, or the log file says blahh, or my debugging showed it didnt like this response from Paypal" then someone will be more likely to take a look.

I know we shouldnt have to do it, but the Magento core team is not that big, and they have a million and one issues to deal with so anything you can do to catch their attention and make it easier to resolve can only help.

First step I would look at is to enable debug logging for paypal, and then look at the payment logs to see what was passed to Paypal, and what the response was back from Paypal for a transaction that works, and then compare the log to one that didn't work. That might give us a clue.

gwharton commented 6 years ago

Although a quick look at the logs from @Cristiano81 posted earlier would suggest that the first exchange between magento and paypal are the same for both transactions that work, and transactions that don't.

chequille commented 6 years ago

Hi gwharton, in your point of view I can understand this as well. But, let's assume, I am a stupid user who just wants to use the shop? I have a new version installed and there are new bugs. Things which worked now not working. This is quit not very funny. Ok, I am not the real stupid user and have already shown in my videos, that when closing the new window after clicking to preceed and than clicking on the Link in the backround "Continue to paypal" it works. To help as much as I can, here is the difference in the URL requests:

The new window is trying to access: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-12189891SW258401V&useraction=commit&sessionID=ffd4e0c315_giytumrqhi2ti&env=sandbox&locale.x=en_US&logLevel=warn&uid=f2f5727f39&version=4&xcomponent=1

When closing the window and clicking the "COntinue to PayPal" Link this is the accessed page: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1WP252449W822913P&useraction=commit

This is already a big difference and my frist question is why in the first URL there is given local.x=en_US My shop is set to de_DE and not to en_US. As well the much more simple request of the second example is working. Strange or? I try to get more infos to find the bug, but sorry, what about the EE edition? Nobody had the problem yet? BR Chequille

chequille commented 6 years ago

Of course with "Stupid user" I mean a user of the software who is not a developer. Hopfefully nobody is angry now !?!?!?!?!?! Forget about the word stupid :-)

gwharton commented 6 years ago

I know what you mean. It seems to use magento these days you need to be a programmer. I struggle and im a programmer so i do wonder how non programmers get by sometimes.

chequille commented 6 years ago

Exactly this is what I mean !!!!

chequille commented 6 years ago

Hi again, more possible help :-)

Attached the logs from the working and the none working case. As I see in the logs, in the none working case, the method GetExpressCheckoutDetails is not executed. Of course PayPal is waiting for this and is going into a timeout after a while and is than returning the canceled message. In the working case, this nethod is called and PayPal is responding and showing the pages to login and so on. This is my analyses of this issue. If it is correct I don't know. This is now part of the real developers :-) to find out what's wrong.

Hopw I could help findng the problem. BR Chequille notworking.txt working.txt

gwharton commented 6 years ago

Can you confirm if it works if you disable In-Context Checkout in the paypal settings.

gwharton commented 6 years ago

Here's my quick look findings.

Magento 2.2.0 stock install - FAILS 100% of the time Magento 2.2.3 stock install - FAILS 100% of the time Magento 2.2.4 stock install - FAILS 100% of the time

If you disable in context checkout it succeeds 100% of the time (although obviously you don't get in context checkout)

If you enable the Paypal Checkout button on the shopping cart then hitting that button works 100% of the time, even with in context checkout enabled.

Failures only occur when you go through Magento checkout.

@chequille I dont think Paypal is timing out. I'm not sure whats going on to be honest. The "GetExpressCheckoutDetails" messages are normally exchanged post paypal logon. The reason why you don't see it is the paypal logon screen is exiting before that message is due.

The first stage of getting a paypal access token certainly succeeds. Immediately after the paypal window exits, if you manually fire up a browser window and go to the url

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<yourtokenhere>&useraction=commit

Then you are presented with the login screen with the correct basket totals. This seems to indicate to me that the token is valid with Paypal.

If you look at the Paypal Developer website and login to view your Sandbox API access logs, then you can see the token requests made to Paypal, and they all have a warning triangle next to them, indicating that Paypal thought something was wrong.

The other option I though of, was in-context checkout is only available if certain criteria are met. If they are not met, then the Paypal window would close (or maybe it wouldnt open in the first place, i dunno), and the browser would be redirected to the legacy Paypal login screen for you to pay. I wonder if that is happening for some reason, and the redirect to paypal is not working. I know in context is not available for Digital goods, or if you want to allow changing the shipping address in paypal and support getting live shipping quotes through to paypal for example.

gwharton commented 6 years ago

@ArjenMiedema Hi there, something definately seems to have changed at Paypal. My Magento 2.2.3 site stopped working last week (or maybe the week before) so I switched over to using Paypal via Braintree. Now people are reporting its not working for them. I did test deployments of 2.2.0, 2.2.3 and 2.2.4 and it is 100% reproducible in all three versions, and I know that 2.2.0 and 2.2.3 used to work, as I used them.

chequille commented 6 years ago

Hi gwharton,

no, it is not working on my site as well with In Context checkout disabled. As well not when going directly through the mini cart.

Same behaviour with both case. BR Chequille

joni-jones commented 6 years ago

Hi, @chequille, @gwharton. This issue is caused by changes in PayPal API and affects only In-Context Express Checkout. PayPal was upgraded their checkout.js API and changed URL for In-Context checkout - https://developer.paypal.com/docs/integration/direct/express-checkout/in-context-checkout-overview/.

Magento uses https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXX&useraction=commit URL to initialize In-Context Flow but PayPal changed this URL to new https://www.sandbox.paypal.com/checkoutnow?token=EC-XXXXX.

As Magento uses PayPal JS SDK https://www.paypalobjects.com/api/checkout.js and PayPal doesn't support versioning in their SDK, changes in SDK affected integration flow in Magento (Magento integration designed to work with JS v3.x but PayPal updated to JS v4.x with the same URL).

Now, Magento team works to solve this issue ASAP, as fast workaround: You need to check in \Magento\Paypal\Controller\Express\GetToken::execute if In-Context is enabled and change the $url to 'https://www.sandbox.paypal.com/checkoutnow?token=' . $token (or without sandbox for production).

joni-jones commented 6 years ago

UPD: Internal ticket MAGETWO-91209.

chequille commented 6 years ago

Hi All, the workaround with the url change is working on my site. Thanks for the moment :-) BR Chequille

misha-kotov commented 6 years ago

It seems like some changes might've happened on the PayPal side in the last few days to revert changes or fix the original issue. Can anyone confirm?

chequille commented 6 years ago

Hi Misha, yes, it really seems so. I aktivated the original code line for the url and removed the workaround and it is working. To be sure, I tried three times and all orders went through.

It should have to be confirmed by the development team, but I guess other systems might have had the same problem and PayPal was informed and they fixed it.

So far my comments. Regards Chequille

misha-kotov commented 6 years ago

Thanks for confirming! Closing.

brianrootways commented 4 years ago

Hello,

I am getting an error (Something went wrong with your request. Please try again later.) while doing PayPal express checkout in firefox especially and redirect to PayPal website. In chrome, edge etc. working fine. Here I give you screenshot for better understanding.

paypal-express