diff --git a/Block/QuickPay.php b/Block/QuickPay.php new file mode 100644 index 0000000..cfcc4c9 --- /dev/null +++ b/Block/QuickPay.php @@ -0,0 +1,50 @@ +configProvider = $configProvider; + } + + /** + * Return payment logo, label, and description based on selected payment method + * + * @param string $methodCode + * @return array + */ + public function getPaymentConfigByMethod(string $methodCode) + { + $config = $this->configProvider->getConfig(); + $methodConfig = $config['payment'][$methodCode] ?? null; + + return [ + 'paymentLogo' => $methodConfig['paymentLogo'] ?? [], + 'description' => $this->configProvider->getDescription($methodCode), + 'label' => $methodCode + ]; + } +} diff --git a/Plugin/Hyva/Checkout/MethodListPlugin.php b/Plugin/Hyva/Checkout/MethodListPlugin.php deleted file mode 100644 index a197f8c..0000000 --- a/Plugin/Hyva/Checkout/MethodListPlugin.php +++ /dev/null @@ -1,86 +0,0 @@ -configProvider = $configProvider; - $this->methodMetaDataFactory = $methodMetaDataFactory; - $this->logger = $logger; - } - - /** - * After getting method metadata, add QuickPay specific data from ConfigProvider - */ - public function afterGetMethodMetaData( - $subject, - $result, - Template $parent, - PaymentMethodInterface $method - ) { - // Check if Hyva classes are available - if (!interface_exists('Hyva\Checkout\Model\MethodMetaDataInterface') || - !class_exists('Hyva\Checkout\Model\MethodMetaDataFactory')) { - return $result; - } - $methodCode = $method->getCode(); - - // Check if it's a QuickPay payment method - if (strpos($methodCode, 'quickpay') === 0) { - try { - $config = $this->configProvider->getConfig(); - $paymentConfig = $config['payment'][$methodCode] ?? []; - - // Add icon data if available (use paymentLogo for both Luma and Hyva compatibility) - if (isset($paymentConfig['paymentLogoPath']) && is_array($paymentConfig['paymentLogoPath'])) { - if (!empty($paymentConfig['paymentLogoPath'])) { - // Use only the first logo (Hyva checkout limitation) - $firstLogo = $paymentConfig['paymentLogoPath'][0]; - - $iconData = [ - 'src' => $firstLogo, - 'attributes' => [ - 'width' => '60', - 'height' => '', - 'alt' => $methodCode - ] - ]; - - $result->setData('icon', $iconData); - } - } - - // Add description as subtitle if available - if (isset($paymentConfig['description']) && !empty($paymentConfig['description'])) { - $result->setData('subtitle', $paymentConfig['description']); - } - } catch (\Exception $e) { - $this->logger->error('QuickPay MethodListPlugin: Error processing ' . $methodCode, ['exception' => $e]); - } - } - - return $result; - } -} diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index 5f5e28c..50789ae 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -27,14 +27,4 @@ type="QuickPay\Gateway\Plugin\Hyva\Checkout\PlaceOrderServiceProcessorPlugin" sortOrder="10"/> - - - - - - - - - \ No newline at end of file + diff --git a/view/frontend/layout/hyva_checkout_components.xml b/view/frontend/layout/hyva_checkout_components.xml new file mode 100644 index 0000000..73f4cec --- /dev/null +++ b/view/frontend/layout/hyva_checkout_components.xml @@ -0,0 +1,62 @@ + + + + + + + quickpay_gateway + + + + + quickpay_klarna + + + + + quickpay_applepay + + + + + quickpay_mobilepay + + + + + quickpay_vipps + + + + + quickpay_paypal + + + + + quickpay_viabill + + + + + quickpay_swish + + + + + quickpay_trustly + + + + + quickpay_anyday + + + + + quickpay_googlepay + + + + + diff --git a/view/frontend/templates/component/payment/method/quickpay.phtml b/view/frontend/templates/component/payment/method/quickpay.phtml new file mode 100644 index 0000000..4e4aa61 --- /dev/null +++ b/view/frontend/templates/component/payment/method/quickpay.phtml @@ -0,0 +1,33 @@ +getMethodCode(); +$config = $block->getPaymentConfigByMethod($methodCode); + +$logos = $config['paymentLogo'] ?? []; +$description = $config['description'] ?? ''; +$label = $config['label'] ?? ''; +?> + + +
+ +
+ + <?= $escaper->escapeHtmlAttr($label) ?> + +
+ + +
+ escapeHtml($description) ?> +
+ +