Skip to main content

Error when adding Paypal Checkout payment method from vendor control panel

More
3 years 2 weeks ago #355237 by trevsmiff
-- HikaShop version -- : 4.7.5
-- Joomla version -- : 4.3.4
-- PHP version -- : 8.1
-- Error-message(debug-mod must be tuned on) -- : 0 in_array(): Argument #2 ($haystack) must be of type array, string given

Hi

When trying to add the HikaShop Paypal Checkout payment plugin using the vendor control panel it throws the following error:
Code:
0 in_array(): Argument #2 ($haystack) must be of type array, string given
If I switch PHP from 8.1 to 7.4 the error goes away.

Other payment methods can be added OK and the PayPal Checkout method can be added from the admin area.

The callstack is:
Code:
# Function Location 1 () JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:723 2 in_array() JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:723 3 pluginmarketViewpluginmarket->processConfig() JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:578 4 pluginmarketViewpluginmarket->loadPluginTemplate() JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:383 5 pluginmarketViewpluginmarket->form() JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:27 6 pluginmarketViewpluginmarket->display() JROOT/libraries/src/MVC/Controller/BaseController.php:645 7 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/administrator/components/com_hikamarket/helpers/helper.php:1646 8 hikamarketController->display() JROOT/components/com_hikamarket/controllers/plugin.php:145 9 pluginMarketController->edit() JROOT/libraries/src/MVC/Controller/BaseController.php:678 10 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/administrator/components/com_hikamarket/helpers/helper.php:1712 11 hikamarketController->execute() JROOT/components/com_hikamarket/hikamarket.php:76 12 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71 13 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73 14 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361 15 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208 16 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249 17 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293 18 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61 19 require_once() JROOT/index.php:32

regards
Trevor

Please Log in or Create an account to join the conversation.

More
3 years 2 weeks ago #355241 by Jerome
Hello,

Can you please confirm me your HikaMarket version number and the content of the line 723 for the pluginmarket/view/html.php file ?

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
3 years 2 weeks ago #355243 by trevsmiff
Hi Jerome

The Hikamarket version is: 4.1.1

Line 723 in pluginmarket/view/html.php file is:
Code:
if(in_array($listKey, $data))

regards
Trevor

Please Log in or Create an account to join the conversation.

More
3 years 2 weeks ago #355270 by Jerome
Hello,

Please replace the line with
Code:
if(in_array($data, $listKey))

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
3 years 2 weeks ago #355271 by trevsmiff
Hi Jerome

I have changed that line and cleaned the cache but the problem persists.
Code:
foreach($config['data'] as $listKey => $listData) { $checked = ''; if(!empty($data)) { if(in_array($data, $listKey)) $checked = 'checked="checked"'; }
Code:
0 in_array(): Argument #2 ($haystack) must be of type array, string given Call stack # Function Location 1 () JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:723 2 in_array() JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:723 3 pluginmarketViewpluginmarket->processConfig() JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:578 4 pluginmarketViewpluginmarket->loadPluginTemplate() JROOT/components/com_hikamarket/views/pluginmarket/view.html.php:383

Regards
Trevor

Please Log in or Create an account to join the conversation.

More
3 years 2 weeks ago #355277 by Jerome
Hello,

Sorry, my bad!
The arguments are in the right order but the content of $data is not an array while it should be. I read it too fast, I shouldn't..

Please restore the previous content and replace the line
Code:
foreach($config['data'] as $listKey => $listData) {
By
Code:
if(!empty($data) && is_string($data)) $data = explode(',', trim($data, ',')); foreach($config['data'] as $listKey => $listData) {
And it will convert the string into an array so it can handle the checkboxes values.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago - 3 years 1 week ago #355278 by trevsmiff
Hi Jerome

Thanks for that, the error has gone but the page is not being rendered correctly. (an unrelated problem I think).
The page is being rendered twice. At the top of the page the form it is rendered without any formatting and below there is a correctly formatted version of the page (see attachment).

There is an error displayed in the console:
Code:
Uncaught SyntaxError: expected expression, got '<' subtask-edit:190:9


Last edit: 3 years 1 week ago by trevsmiff.

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago #355281 by nicolas
Hi,

We're not sure what's going on.

Could you provide a vendor account, a backend access and a FTP access so that we could directly look at what's going on ?
You can provide all this via our contact form:
www.hikashop.com/support/contact-us.html

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago #355303 by trevsmiff
Hi

Details sent as requested.

btw. I tried switching the template to Cassopeia and changing the PHP version to 7.4 but the result was the same

regards
Trevor

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago #355362 by Jerome
Hello,

Thank you for the accesses.

We applied a patch on the Paypal Checkout plugin in your website; it improves the compatibility with HikaMarket.

Joomla 4 does handle the JavaScript differently in the backend than the front-end, which was causing:
1 - A wrong extraction of javascript in the HTML page.
2 - A modification of the initialization sequence.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago #355383 by trevsmiff
Thanks for sorting that Jerome, the page is now rendering correctly.

The 'Connect to PayPal Checkout ' doesn't seem to work however but I suspect that might be something to do with PayPal. After clicking the button I am asked to log in to PayPal several times but the API codes are not returned and have to be entered manually.

I am away from my office at the moment and will test more thoroughly when I return.

Best regards
Trevor

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago #355390 by nicolas
Hi,

I see what you mean. I'm indeed able to reproduce the issue on your website.
However, there are no errors or strange thing as far as I can see.
It's just that the paypal onboarding popup doesn't callback the plugin's function to process the onboarding on the server side to automatically fill in the fields for you.
I'm afraid we'll have to contact the PayPal technical engineer we know there to check with them what they can find.

It might take a while...

In the mean time, a simple solution would be to add:
Code:
if(!hikashop_isClient('administrator')) { unset($this->pluginConfig['connect']); return; }
after the line:
Code:
parent::onPaymentConfiguration($element);
in the file plugins/hikashoppayment/paypalcheckout/paypalcheckout.php
That will remove the connect button and vendors will have to manually enter their credentials.

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago #355393 by trevsmiff
Hi Nicolas

Thanks for confirming that. Good luck with PayPal.

Best regards
Trevor

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.229 seconds
Powered by Kunena Forum