Magento2: Paypal issue with region on 2.3.4

Created on 4 Feb 2020  路  53Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento 2.3.4 & 2.4-develop
  2. Clean version, vanilla, with sample data only
  3. PHP 7.2.26
  4. Paypal Express Checkout

Steps to reproduce (*)

  1. Enable paypal w/o review (haven't tried with review)
  2. Add product to cart as guest or logged in (doesn't matter)
  3. Go to checkout
  4. Enter your shipping address to be in UK for example and enter some state, I used Nottinghamshire
  5. Place order, confirm from paypal side
  6. You will get error 500

Expected result (*)

  1. Successfully placed order

Actual result (*)

  1. Error 500: NOTICE: PHP message: PHP Fatal error: Uncaught Error: Call to a member function getId() on null in httpdocs/vendor/magento/module-paypal/Model/Api/Nvp.php:1527

When I ported back code from 2.3.3 for _applyStreetAndRegionWorkarounds function, it worked.

$regions->getItems() in _applyStreetAndRegionWorkarounds is empty.

Paypal Fixed in 2.3.x Fixed in 2.4.x Clear Description Confirmed Format is valid Ready for Work Reported on 2.3.3 Reproduced on 2.4.x good first issue

Most helpful comment

It looks like Magento has released a hotfix for this problem on: https://magento.com/tech-resources/download#download2353

Maybe somebody running into this issue can test and report back if this fixes it for them?

All 53 comments

Thanks for opening this issue!

Hi @kerlama. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@kerlama do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Same problem

happens to us too after a manual upgrade of enterprise edition. @kerlama @justStanislav are you using enterprise edition of magento2?

@medigeek no, I am on open source one.

@medigeek no, community.

@kerlama @justStanislav did you use manual upgrade or composer upgrade?
@fascinosum could you have a look at this please? some changes were introduced in Nvp.php ( https://github.com/magento/magento2/commit/42c26724382bcafe0ccdc84cc9fe53427891aadd ) that affect the paypal module, instead of a success page we end up with http error 500 and the error kerlama mentioned in the logs.

@medigeek composer upgrade from 2.3.3.

@medigeek same way like @kerlama

Thank you both. :) @kerlama I see you have already tested this on a vanilla installation as you have originally posted. I'm not sure if you can reply to the @magento bot "yes" or tick it, don't know how this github bots work heh.
Let's wait on @fascinosum or someone else to check this out.

@magento give me 2.4-develop instance

Hi @kerlama. Thank you for your request. I'm working on Magento 2.4-develop instance for you

Hello
I upgraded Enterprise Edition 2.3.3 to 2.3.4 manually. Then I got the same error.
HTTP Error 500
Also I can see an error in Nvp.php:1524.

Hi @kerlama, here is your Magento instance.
Admin access: https://i-26698-2-4-develop.instances.magento-community.engineering/admin_8452
Login: 5d6faf61 Password: c38757c25a07
Instance will be terminated in up to 3 hours.

@magento give me 2.3.4 instance

Hi @kerlama. Thank you for your request. I'm working on Magento 2.3.4 instance for you

Hi @kerlama, here is your Magento instance.
Admin access: https://i-26698-2-3-4.instances.magento-community.engineering/admin_352b
Login: 45be4a03 Password: 9a705053948c
Instance will be terminated in up to 3 hours.

Hi, I replaced some codes in function _applyStreetAndRegionWorkarounds(DataObject $address) to ones of 2.3.3.

        - $regionItems = $regions->getItems();
        - $region = array_shift($regionItems);
        - $address->setRegionId($region->getId());
        - $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));

        + foreach ($regions as $region) {
           + $address->setRegionId($region->getId());
           + $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));
           + break;
       + }

Then tested again. So it worked, but it was redirected to the order review page.
I can see the error message on the page and can't place the order.
image

Any idea?

@noeli-eshopguru code from 2.3.3 works fine for me (_applyStreetAndRegionWorkarounds).

@magento-engcom-team I was able to reproduce the issue on clean instance you gave me.

Screenshot_15

Hi @kerlama but why am I getting the error on the order review page?
And I have already enabled the review page skip option on the paypal settings.
Are you moving to the order success page correctly?

@noeli-eshopguru yes, for me its working fine, payment is charged and I am redirected to success page.

Hi @kerlama, do you have any idea with my error?

@noeli-eshopguru not sure, there are few places where this exception is thrown, see at which one it fails and then check if you have any custom observer which might affect on it.

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Thanks for opening this issue!

:white_check_mark: Confirmed by @engcom-Hotel
Thank you for verifying the issue. Based on the provided information internal tickets MC-31196 were created

Issue Available: @engcom-Hotel, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

@kerlama, @medigeek, thank you
@odubovyk, you may have more information as the author of these changes. Could you have a look at this issue?

Also experiencing on 2.3.4 CE. Composer upgrade from 2.3.3 on 10 Feb.

Order success as expected when using Safari, IE, Edge. However we are receiving a 500 Error when using the chrome browser across Windows/OSX/IOS platforms. Browser history鈥檚/cookies cleared, Magento cache cleared/flushed but bug persists.

Debug currently switched on and will continue looking tomorrow and will update if I find anything.

Upgraded from CE 2.3.3 > 2.3.4 via composer and similar issue.
At first I thought it was JS Bundling that I had enabled.
Im using Paypal Standard.
When returning from Paypal to site get blank page with url of /paypal/express/return/?token=XXXXXXXXXX&PayerID=XXXXXXXXXX

Error log shows:
`[11-Feb-2020 16:36:10 UTC] PHP Fatal error: Uncaught Error: Call to a member function getId() on null in /home/public_html/vendor/magento/module-paypal/Model/Api/Nvp.php:1524
Stack trace:

0 /home/public_html/vendor/magento/module-paypal/Model/Api/Nvp.php(1493): Magento\PaypalModelApi\Nvp->_applyStreetAndRegionWorkarounds(Object(Magento\Framework\DataObject))

1 /home/public_html/vendor/magento/module-paypal/Model/Api/Nvp.php(849): Magento\PaypalModelApi\Nvp->_exportAddresses(Array)

2 /home/public_html/vendor/magento/module-paypal/Model/Express/Checkout.php(621): Magento\PaypalModelApi\Nvp->callGetExpressCheckoutDetails()

3 /home/public_html/vendor/magento/module-paypal/Controller/Express/AbstractExpress/ReturnAction.php(32): Magento\PaypalModel\Express\Checkout->returnFromPaypal('EC-9JN953126P91...')

4 /home/public_html/vendor/magento/framework/App/Action/Action.php(108): Magento\Paypal\Controller\ExpressAbstractExpress\ReturnAction->execute()

5 /home/ in /home/public_html/vendor/magento/module-paypal/Model/Api/Nvp.php on line 1524`

Order does not get logged in admin.

Having the same issue, causing a lot of website sales to go!

Anyone found a fix? need it asap!

I don't get how Magento release something that's so dam buggy!

Having the same issue, causing a lot of website sales to go!

Anyone found a fix? need it asap!

I don't get how Magento release something that's so dam buggy!

Revert back the function _applyStreetAndRegionWorkarounds from 2.3.3 in vendor/magento/module-paypal/Model/Api/Nvp.php

@jackrevate

I can confirm that @joridos fix is working for us.

He has been unable to merge due to an error but it appears the error is at line 1618 which was already part of 3.2.4 core and he hasn't even touched! All checks for CE and EE passed.

@stu583 yes, the only one error is on a method that I haven't changed

@joridos

Yes I had a look and its very odd. I agree that it's not anywhere near the the method you edited. Maybe already buggy, shouldn't have passed previously and never have made the 2.3.4? I don't know.

Like I said its working perfectly for us. We are taking PayPal payments, in production, with no problems since applying your fix. Thanks for the contribution. 馃檪

Yes @joridos fix works for us also. Thank you

Personally I am getting very tired of issues arising in patch versions of Magento. 2.3.4 has introduced two major payment bugs - one for Paypal which should NOT have happened and one for certain third party vendor payment methods, such as Magenticity SagePay, see here: 2.3.4 Checkout Infinite Loop. How does this happen?!

It looks like Magento has released a hotfix for this problem on: https://magento.com/tech-resources/download#download2353

Maybe somebody running into this issue can test and report back if this fixes it for them?

The patch did not fix it for me.
before I had an: internal Error..... Report ID: webapi
and now the an: Infiniteloo detected, review the trace for the looping path

Infinite loop detected appeared due to a third party extension 'Stripe' - they have released a newer version.

We do not have stripe either and found that 1 third party tier pricing module was responsible.

@Emilietrepanier Is it maybe from MageWorx, as we do have their extension installed, to add fees.

Yes it was MageWorx extension. We updated it and it's all good now.

@Grumag For us it was Blue Jalapeno Tier Pricing

Hi @kerlama.

Thank you for your report and collaboration!

The issue was fixed by Magento team. The fix was delivered into magento/magento2:2.3-develop branch(es).
Related commit(s):

The fix will be available with the upcoming 2.3.5 release.

I have tested applying the patch @hostep mentioned in 2.3.4 Cloud instance and it works

Anyone has a fix for this that actually works. Getting a http error instead of the magento success page with paypal express and braintree/paypal module. Nothing in this thread actually works. Thanks

Hi @kerlama.

Thank you for your report and collaboration!

The issue was fixed by Magento team. The fix was delivered into magento/magento2:2.4-develop branch(es).
Related commit(s):

The fix will be available with the upcoming 2.4.0 release.

@Grumag For us it was Blue Jalapeno Tier Pricing

Did you find a fix? I use this module.

Any solution>?

Failed to connect to 127.0.0.1 port 808: Connection refused at /home/luckyeyesinc/public_html/vendor/magento/module-paypal/Model/Api/Nvp.php:1215)"} []

Hello
I upgraded Enterprise Edition 2.3.3 to 2.3.4 manually. Then I got the same error.
HTTP Error 500
Also I can see an error in Nvp.php:1524.

Did you find any solution?

@noeli-eshopguru Are you directly update code or using any model or preference to achieve this edit?

FYI - I am using multi-website, website 1 for USA website 2 for Australia i am using Paypal for my MultiWebsite, here website 1(USA) working good, website 2(Australia) getting error.

Error: If my website 2 customer tries to pay PayPal getting the following error, but website 1 PayPal working well.

Fatal error: Uncaught Error: Call to a member function getId() on null in /var/www/html/test/app/code/Magento/Paypal/Model/Api/Nvp.php:1524

The Conclusion, shall i go with patch or edit code (What is the recommended way to edit the file)?

Does anyone have a solution?

@magento-engcom-team I'm getting the same error in 2.4.1 can anyone else confirm?

I get the error below when trying to apply the patch PayPal_Express_Checkout_issue_fix_2.3.4_composer-2020-02-13-12-34-09.patch probably because it's a 2.3.4 patch and I'm on 2.4.1 - can anyone #help?

patching file vendor/magento/module-paypal/Model/Api/Nvp.php Hunk #1 FAILED at 1512. Hunk #2 FAILED at 1624. Hunk #3 FAILED at 1653. Hunk #4 FAILED at 1694. Hunk #5 FAILED at 1712. 5 out of 5 hunks FAILED -- saving rejects to file vendor/magento/module-paypal/Model/Api/Nvp.php.rej

Was this page helpful?
0 / 5 - 0 ratings