Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid argument supplied for foreach() in DigitalWalletConfigProvider #93

Open
bartoszjuszczyk opened this issue Mar 6, 2024 · 1 comment

Comments

@bartoszjuszczyk
Copy link

Magento version: 2.4.4-p2
PayNow version: 1.5.2

There is a line of code in the Paynow\PaymentGateway\Model\Ui\DigitalWalletConfigProvider that retrieves available digital wallets:

$paymentMethods = $this->paymentMethodsHelper->getDigitalWalletsPaymentMethods($currencyCode, $grandTotal);

It is followed by a foreach to which they are passed:

foreach ($paymentMethods as $paymentMethod) {
    if (in_array(PaymentMethodsToHide::PAYMENT_TYPE_TO_CONFIG_MAP[$paymentMethod['type'] ?? ''] ?? '', $this->configHelper->getPaymentMethodsToHide())) {
        $isActive = false;
        break;
    }
}

However, there is no check for null returned, causing an error to occur:

[2024-03-06T13:24:12.663499+00:00] main.CRITICAL: Exception: Warning: Invalid argument supplied for foreach() in /var/www/html/vendor/pay-now/paynow-magento2/Model/Ui/DigitalWalletConfigProvider.php on line 34 in /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61

This error can cause the checkout to display incorrectly or not to display at all.

@bartoszjuszczyk
Copy link
Author

PR: #94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant