foxnetwork Posted September 15, 2023 Share Posted September 15, 2023 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 More sharing options...
ComGrafPL Posted September 15, 2023 Share Posted September 15, 2023 What's your PHP version? 1 Link to comment Share on other sites More sharing options...
foxnetwork Posted September 15, 2023 Author Share Posted September 15, 2023 php 7.4 Link to comment Share on other sites More sharing options...
foxnetwork Posted September 17, 2023 Author Share Posted September 17, 2023 can anyone help with this problem. Really don't want to downgrade to 1.6 again Link to comment Share on other sites More sharing options...
ComGrafPL Posted September 17, 2023 Share Posted September 17, 2023 (edited) 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 September 17, 2023 by ComGrafPL (see edit history) Link to comment Share on other sites More sharing options...
Yelish Posted September 18, 2023 Share Posted September 18, 2023 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 More sharing options...
foxnetwork Posted September 18, 2023 Author Share Posted September 18, 2023 Yeah I noticed the module worked in 1.7.8 but not in 8.1 I have contacted prestashop developer but no answer. It's a shame it all works up to the checkout. Looks like will have to downgrade until they fix the module Link to comment Share on other sites More sharing options...
Yelish Posted September 18, 2023 Share Posted September 18, 2023 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); } } 1 Link to comment Share on other sites More sharing options...
foxnetwork Posted September 18, 2023 Author Share Posted September 18, 2023 I have no Idea what I am doing since 1.6 can I give you the module itself. The error I think is coming from the RAPIDAPI.php in lib dir of module where it tries to get the initial connection v3.4.6-ewayrapid.zip Link to comment Share on other sites More sharing options...
Yelish Posted September 18, 2023 Share Posted September 18, 2023 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 More sharing options...
Yelish Posted September 18, 2023 Share Posted September 18, 2023 I'll now send you the file privately. Best regards, and have a great day. Link to comment Share on other sites More sharing options...
foxnetwork Posted September 18, 2023 Author Share Posted September 18, 2023 thank you so much Link to comment Share on other sites More sharing options...
Yelish Posted September 18, 2023 Share Posted September 18, 2023 It doesn't deserve them, and I'm here to help the community. I can't always be here, but when I can, I help. Let me know. 1 Link to comment Share on other sites More sharing options...
foxnetwork Posted September 18, 2023 Author Share Posted September 18, 2023 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 More sharing options...
foxnetwork Posted September 18, 2023 Author Share Posted September 18, 2023 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 More sharing options...
foxnetwork Posted September 19, 2023 Author Share Posted September 19, 2023 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 More sharing options...
Yelish Posted September 20, 2023 Share Posted September 20, 2023 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 More sharing options...
Paul C Posted March 29 Share Posted March 29 (edited) 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 March 29 by Paul C typo (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now