Jump to content

Problem with prestashop eway payments module


Recommended Posts

I am having a problem with prestashops add-on eway payments. I know it says it only goes to 1.7 but I am running 8.1. It installed ok I configure it and save ok I go to add product in cart and then click checkout I get blank screen. With debug on I get

Fatal error: Uncaught Error: Call to undefined method Tools::jsonEncode() in /home/foxsecur/public_html/new/modules/ewayrapid/lib/eWAY/RapidAPI.php:187 Stack trace: #0 /home/foxsecur/public_html/new/modules/ewayrapid/lib/eWAY/RapidAPI.php(91): EwayRapidAPI->fixObjtoJSON(Object(EwayCreateAccessCodeRequest)) #1 /home/foxsecur/public_html/new/modules/ewayrapid/ewayrapid.php(661): EwayRapidAPI->createAccessCodesShared(Object(EwayCreateAccessCodeRequest)) #2 /home/foxsecur/public_html/new/classes/Hook.php(993): Ewayrapid->hookPaymentOptions(Array) #3 /home/foxsecur/public_html/new/classes/Hook.php(418): HookCore::coreCallHook(Object(Ewayrapid), 'hookPaymentOpti...', Array) #4 /home/foxsecur/public_html/new/classes/Hook.php(928): HookCore::callHookOn(Object(Ewayrapid), 'paymentOptions', Array) #5 /home/foxsecur/public_html/new/src/Adapter/HookManager.php(81): HookCore::exec('paymentOptions', Array, NULL, true, true, false, NULL) #6 /home/foxsecur/public_html/new/src/PrestaShopBundle/Service/Hook/HookFinder.php(70): PrestaShop\P in /home/foxsecur/public_html/new/modules/ewayrapid/lib/eWAY/RapidAPI.php on line 187

It's not loading rest of checkout page. If I disable module or reset module I get checkout page without eway.

Any help appreciated to get this module up an running so I can put shop back online

Link to comment
Share on other sites

Have you tried to run it on PHP 8+? Also, module is updated to run in PS 8.1?

Last official version is 3.4.6 / Last update 01/2018 up to PS version 1.7.6

Are you using default presta checkout or custom one?

I've had similar issue with other payments module on custom checkout. What i did i have removed both payments and checkout module. Then i install payments and then checkout. It's working fine now. Seems in some cases checkout dont see new payment options, when you added after.

Also ask developer if they have any updated versions official one or thise one https://www.modulebazaar.com/prestashop-eway-payments-australia-module/00100024

Edited by ComGrafPL (see edit history)
Link to comment
Share on other sites

Hello, how are you? Let's see, many things have changed in PrestaShop 8, one of the main changes being that you can no longer access methods that traditionally were part of PHP through the Tools class. In my modules, what I do is check the PrestaShop version, and based on that, I use one function or another. In your particular case, you are making calls to functions that no longer exist in the Tools class, and this is not due to your PHP version but your PrestaShop version. Best regards, and have a great day!

Link to comment
Share on other sites

No, if you provide me with the file that's causing you trouble, I'll try to correct it. Please keep in mind that this is something I do for the community, and you don't need to give me any form of compensation. If you're a developer and can do it yourself, it's quite simple. Make a call to the module's class and from there, check if the method exists in the Tools class. If it doesn't, add a function in the class that does the necessary task.

    public static function encodeJson($arr)
    {
        if (method_exists('Tools', 'jsonEncode')) {
            return Tools::jsonEncode($arr);
        } else {
            return json_encode($arr);
        }
    }

 

  • Thanks 1
Link to comment
Share on other sites

Thank you very much for your trust, but it's better for you to send me these types of files privately through the forum's email. Nonetheless, I'll take a look and see if I can figure something out. Contrary to what users often think, reverse-engineering modules that are already developed can be challenging, but I'll do my best. Best regards, and have a great day.

Link to comment
Share on other sites

Tried with module reinstalled and getting new error codes on checkout

Fatal error: Uncaught Error: Call to undefined method Tools::jsonDecode() in /home/foxsecur/public_html/shop8/modules/ewayrapid/lib/eWAY/RapidAPI.php:240 Stack trace: #0 /home/foxsecur/public_html/shop8/modules/ewayrapid/lib/eWAY/RapidAPI.php(92): EwayRapidAPI->postToRapidAPI('https://api.san...', '{"Customer":{"T...') #1 /home/foxsecur/public_html/shop8/modules/ewayrapid/ewayrapid.php(661): EwayRapidAPI->createAccessCodesShared('{"Customer":{"T...') #2 /home/foxsecur/public_html/shop8/classes/Hook.php(993): Ewayrapid->hookPaymentOptions(Array) #3 /home/foxsecur/public_html/shop8/classes/Hook.php(418): HookCore::coreCallHook(Object(Ewayrapid), 'hookPaymentOpti...', Array) #4 /home/foxsecur/public_html/shop8/classes/Hook.php(928): HookCore::callHookOn(Object(Ewayrapid), 'paymentOptions', Array) #5 /home/foxsecur/public_html/shop8/src/Adapter/HookManager.php(81): HookCore::exec('paymentOptions', Array, NULL, true, true, false, NULL) #6 /home/foxsecur/public_html/shop8/src/PrestaShopBundle/Service/Hook/HookFinder.php(70): Pr in /home/foxsecur/public_html/shop8/modules/ewayrapid/lib/eWAY/RapidAPI.php on line 240

Link to comment
Share on other sites

I also get this in back office when I configure I don't know f this has anything to do with it

 

Unknown error on line 875 in file /home/foxsecur/public_html/shop8/classes/Hook.php
[16384] The hook "backOfficeHeader" is deprecated, please use "displayBackOfficeHeader" instead in module "ewayrapid".

Link to comment
Share on other sites

I found the problem. The above just needs the hook changed the error coming up in checkout is caused by depreciated encode

 

Deprecations and removals

This is probably one of the changes that might have the most significant impact on your solutions.

Many classes and methods marked as “deprecated” in previous versions have been removed in PrestaShop 8. These were methods that the core no longer used or that no longer made sense to keep, like wrappers around natively available PHP functions. A typical example of these functions areTools::jsonEncode() and Tools::jsonDecode().

In this case the change is simple, Tools::jsonEncode() must be replaced with json_encode(), and Tools::jsonDecode() with json_decode(). These two functions are natively available in PHP.

Change these and all works ok

Link to comment
Share on other sites

I congratulate you on your solution. The adaptations to the Tools class by PrestaShop are determined by the latest versions of Php 8, where it is not allowed to have functions in classes that correspond to core functions. For backward compatibility, if you are a programmer, I would advise you to create your own functions in classes and work with them based on the state of the client's Tools class. Best regards, and I hope you have a great day.

Link to comment
Share on other sites

  • 6 months later...
On 9/20/2023 at 10:07 AM, Yelish said:

I congratulate you on your solution. The adaptations to the Tools class by PrestaShop are determined by the latest versions of Php 8, where it is not allowed to have functions in classes that correspond to core functions. For backward compatibility, if you are a programmer, I would advise you to create your own functions in classes and work with them based on the state of the client's Tools class. Best regards, and I hope you have a great day.

Nothing to do with PHP 8. Those functions go way, way back. Native functions have existed and were alternatives since PHP 5.2.0.... safe to use json_encode() and json_decode() in modules that need to be backwards compatible with 1.7.

Edited by Paul C
typo (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...