cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3.4 paypal error

Magento 2.3.4 paypal error

Hi everyone,

I'm trying to integrate PayPal as a payment method in my site.

if I try to make a payment the site give me an error in Italian, something like:

"Error on our server. Try again later"

 

The browser console give me a message:

"Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

 

If I click on tantalizer message give me this:

{"success":false,"error_message":"Il gateway di PayPal ha rifiutato la richiesta. Invalid token (#10410: Invalid token)."}

 

 

Some one can help me please? 

Thanks

9 REPLIES 9

Re: Magento 2.3.4 paypal error

Hello @zerod10 

 

Please follow this guide for the solution: 

 

https://support.magento.com/hc/en-us/articles/360039451972-2-3-4-PayPal-Issue-Hotfix

 

I hope it helps you.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Magento 2.3.4 paypal error

Hi, thanks for you reply, with patch I have to apply?

thanks again

Re: Magento 2.3.4 paypal error

@zerod10 , glad to be of some help Smiley Happy

 

Yes, you can apply the patch.

 

Please make sure to take the file and database backup before applying the patch.

Thank you.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Magento 2.3.4 paypal error

fount it, was: 

PayPal_Express_Checkout_issue_fix_2.3.4_github-2020-02-13-12-36-34.patch

 

But now on termina it give me that error: 

can't find file to patch at input line 8
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|Index: app/code/Magento/Paypal/Model/Api/Nvp.php
|IDEA additional info:
|Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|<+>UTF-8
|===================================================================
|--- app/code/Magento/Paypal/Model/Api/Nvp.php (revision 0595b0dbe57711bccb5cdb049bdae9ac8ba8b0cc)
|+++ app/code/Magento/Paypal/Model/Api/Nvp.php (date 1581448283375)
--------------------------
File to patch:

Re: Magento 2.3.4 paypal error

@zerod10 

 

Please try manually to apply the patch.

Thank you.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Magento 2.3.4 paypal error

How?

 

Re: Magento 2.3.4 paypal error

Lol I love how they reply with this vague answers and then want you to accept as solutions so they can get points. 

 

I been using magento 2 for a long time and still don't know how to apply those patches.

Re: Magento 2.3.4 paypal error

Hey @zerod10 

 

Please follow https://github.com/magento/magento2/issues/26698

 

Thank you.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Magento 2.3.4 paypal error

Hey @starlyns ,

 

Might be late but i think the best way to apply (by my experience) is manually, rare the time I can apply it without errors if it isn't by manual so to apply manually download the file .patch then open all you'll see something like this

--- a/vendor/magento/module-paypal/Model/Api/Nvp.php	(revision 0595b0dbe57711bccb5cdb049bdae9ac8ba8b0cc)
+++ b/vendor/magento/module-paypal/Model/Api/Nvp.php	(date 1581448283375)
@@ -1512,17 +1512,17 @@
         }
         // attempt to fetch region_id from directory
         if ($address->getCountryId() && $address->getRegion()) {
-            $regions = $this->_countryFactory->create()->loadByCode(
-                $address->getCountryId()
-            )->getRegionCollection()->addRegionCodeOrNameFilter(
-                $address->getRegion()
-            )->setPageSize(
-                1
-            );
+            $regions = $this->_countryFactory->create()
+                ->getRegionCollection()
+                ->addCountryFilter($address->getCountryId())
+                ->addRegionCodeOrNameFilter($address->getRegion())
+                ->setPageSize(1);
             $regionItems = $regions->getItems();
-            $region = array_shift($regionItems);
-            $address->setRegionId($region->getId());
-            $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));
+            if (count($regionItems)) {
+                $region = array_shift($regionItems);
+                $address->setRegionId($region->getId());
+                $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));
+            }
         }
     }

The first lines until @@ tells the file it's changed and if it changes the name, usually it's the same so in this case the next line are applied to 

/vendor/magento/module-paypal/Model/Api/Nvp.php

and the second is the same path so the file stays with the same name.

Getting to the code itself after the @@ tells you the lines so in this case line 1512 go to that line all you're suppose to see all the code that is after without the ones with the + at the beginning.

So you know where to do the changes, then, remove all the lines that starts with - and add all the lines that starts with +, in this case you should have at those lines 

if ($address->getCountryId() && $address->getRegion()) {
           $regions = $this->_countryFactory->create()->loadByCode(
                $address->getCountryId()
            )->getRegionCollection()->addRegionCodeOrNameFilter(
                $address->getRegion()
            )->setPageSize(1);
            $regionItems = $regions->getItems();
            $region = array_shift($regionItems);
            $address->setRegionId($region->getId());
            $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));
         }
     }

(the lines starting with - and the ones with nothing at the start) and after the changed you'll be with

if ($address->getCountryId() && $address->getRegion()) {
            $regions = $this->_countryFactory->create()
                ->getRegionCollection()
                ->addCountryFilter($address->getCountryId())
                ->addRegionCodeOrNameFilter($address->getRegion())
                ->setPageSize(1);
             $regionItems = $regions->getItems();
            if (count($regionItems)) {
                $region = array_shift($regionItems);
                $address->setRegionId($region->getId());
                $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));
            }
         }
     }

Sorry it may not the that clarifying but hope it helps someday, but it's a time consuming task when you have a .patch the has line 5k lines of code to change.