Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Block/QuickPay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

namespace QuickPay\Gateway\Block;

use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use QuickPay\Gateway\Model\Ui\ConfigProvider;

class QuickPay extends Template
{
/**
* @var ConfigProvider
*/
protected $configProvider;

/**
* QuickPay constructor.
*
* @param Context $context
* @param ConfigProvider $configProvider
*/
public function __construct(
Context $context,
ConfigProvider $configProvider,
array $data = []
) {
parent::__construct($context, $data);
$this->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
];
}
}
86 changes: 0 additions & 86 deletions Plugin/Hyva/Checkout/MethodListPlugin.php

This file was deleted.

12 changes: 1 addition & 11 deletions etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,4 @@
type="QuickPay\Gateway\Plugin\Hyva\Checkout\PlaceOrderServiceProcessorPlugin"
sortOrder="10"/>
</type>


<!-- Plugin to add QuickPay metadata to Hyva checkout payment methods -->
<type name="Hyva\Checkout\ViewModel\Checkout\Payment\MethodList">
<plugin name="quickpay_hyva_checkout_metadata"
type="QuickPay\Gateway\Plugin\Hyva\Checkout\MethodListPlugin"
sortOrder="10"/>
</type>


</config>
</config>
62 changes: 62 additions & 0 deletions view/frontend/layout/hyva_checkout_components.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.payment.methods">
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_gateway" as="quickpay_gateway" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_gateway</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_klarna" as="quickpay_klarna" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_klarna</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_applepay" as="quickpay_applepay" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_applepay</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_mobilepay" as="quickpay_mobilepay" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_mobilepay</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_vipps" as="quickpay_vipps" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_vipps</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_paypal" as="quickpay_paypal" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_paypal</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_viabill" as="quickpay_viabill" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_viabill</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_swish" as="quickpay_swish" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_swish</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_trustly" as="quickpay_trustly" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_trustly</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_anyday" as="quickpay_anyday" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_anyday</argument>
</arguments>
</block>
<block class="QuickPay\Gateway\Block\QuickPay" name="checkout.payment.method.quickpay_googlepay" as="quickpay_googlepay" template="QuickPay_Gateway::component/payment/method/quickpay.phtml">
<arguments>
<argument name="method_code" xsi:type="string">quickpay_googlepay</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
33 changes: 33 additions & 0 deletions view/frontend/templates/component/payment/method/quickpay.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

use Magento\Framework\Escaper;
use QuickPay\Gateway\Block\QuickPay;

/** @var Escaper $escaper */
/** @var QuickPay $block */

$methodCode = $block->getMethodCode();
$config = $block->getPaymentConfigByMethod($methodCode);

$logos = $config['paymentLogo'] ?? [];
$description = $config['description'] ?? '';
$label = $config['label'] ?? '';
?>

<?php /* The wire Payment Method directive is required to sit in the root DOM element. */ ?>
<div class="quickpay-method" data-method="<?= $escaper->escapeHtmlAttr($methodCode) ?>">
<?php if (!empty($logos)): ?>
<div class="quickpay-logos flex flex-wrap items-center gap-1.5">
<?php foreach ($logos as $logo): ?>
<img src="<?= $escaper->escapeUrl($logo) ?>" alt="<?= $escaper->escapeHtmlAttr($label) ?>" width="50" height="33" />
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($description): ?>
<div class="quickpay-description mt-3 p-4 mb-1 bg-gray-100 rounded-lg">
<?= $escaper->escapeHtml($description) ?>
</div>
<?php endif; ?>
</div>