Skip to content

Commit

Permalink
payment method description
Browse files Browse the repository at this point in the history
  • Loading branch information
mareknaujas committed May 3, 2024
1 parent bf392a8 commit 16c00a6
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 12 deletions.
39 changes: 28 additions & 11 deletions Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class ConfigProvider implements ConfigProviderInterface
const CODE_GOOGLEPAY = 'quickpay_googlepay';

const XML_PATH_CARD_LOGO = 'payment/quickpay_gateway/cardlogos';
const XML_PATH_DESCRIPTION = 'payment/%s/description';

protected $scopeConfig;

Expand All @@ -45,37 +46,48 @@ public function getConfig()
'payment' => [
self::CODE => [
'redirectUrl' => 'quickpaygateway/payment/redirect',
'paymentLogo' => $this->getQuickPayCardLogo()
'paymentLogo' => $this->getQuickPayCardLogo(),
'description' => $this->getDescription(self::CODE)
],
self::CODE_KLARNA => [
'paymentLogo' => $this->getKlarnaLogo()
'paymentLogo' => $this->getKlarnaLogo(),
'description' => $this->getDescription(self::CODE_KLARNA)
],
self::CODE_APPLEPAY => [
'paymentLogo' => $this->getApplePayLogo()
'paymentLogo' => $this->getApplePayLogo(),
'description' => $this->getDescription(self::CODE_APPLEPAY)
],
self::CODE_MOBILEPAY => [
'paymentLogo' => $this->getMobilePayLogo()
'paymentLogo' => $this->getMobilePayLogo(),
'description' => $this->getDescription(self::CODE_MOBILEPAY)
],
self::CODE_VIPPS => [
'paymentLogo' => $this->getVippsLogo()
'paymentLogo' => $this->getVippsLogo(),
'description' => $this->getDescription(self::CODE_VIPPS)
],
self::CODE_PAYPAL => [
'paymentLogo' => $this->getPaypalLogo()
'paymentLogo' => $this->getPaypalLogo(),
'description' => $this->getDescription(self::CODE_PAYPAL)
],
self::CODE_VIABILL => [
'paymentLogo' => $this->getViaBillLogo()
'paymentLogo' => $this->getViaBillLogo(),
'description' => $this->getDescription(self::CODE_VIABILL)
],
self::CODE_SWISH => [
'paymentLogo' => $this->getSwishLogo()
'paymentLogo' => $this->getSwishLogo(),
'description' => $this->getDescription(self::CODE_SWISH)
],
self::CODE_TRUSTLY => [
'paymentLogo' => $this->getTrustlyLogo()
'paymentLogo' => $this->getTrustlyLogo(),
'description' => $this->getDescription(self::CODE_TRUSTLY)
],
self::CODE_ANYDAY => [
'paymentLogo' => $this->getAnydayLogo()
'paymentLogo' => $this->getAnydayLogo(),
'description' => $this->getDescription(self::CODE_ANYDAY)
],
self::CODE_GOOGLEPAY => [
'paymentLogo' => $this->getGooglePayLogo()
'paymentLogo' => $this->getGooglePayLogo(),
'description' => $this->getDescription(self::CODE_GOOGLEPAY)
],
]
];
Expand Down Expand Up @@ -104,6 +116,11 @@ public function getQuickPayCardLogo(){
return $items;
}

public function getDescription($method){
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->scopeConfig->getValue(sprintf(self::XML_PATH_DESCRIPTION, $method), $storeScope);
}

public function getKlarnaLogo(){
$items = [];

Expand Down
33 changes: 33 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="apikey" translate="label" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>API key</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
Expand Down Expand Up @@ -126,6 +129,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -153,6 +159,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -180,6 +189,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -207,6 +219,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -234,6 +249,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -261,6 +279,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -288,6 +309,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -319,6 +343,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="min_order_total" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Minimum Order Amount</label>
<validate>validate-number validate-zero-or-greater</validate>
Expand Down Expand Up @@ -351,6 +378,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down Expand Up @@ -378,6 +408,9 @@
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Description</label>
</field>
<field id="order_status" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="QuickPay_Gateway" setup_version="2.4.4">
<module name="QuickPay_Gateway" setup_version="2.4.5">
<sequence>
<module name="Magento_Payment"/>
<module name="Magento_Checkout"/>
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/anyday.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_anyday.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_anyday.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/applepay.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_applepay.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_applepay.description;
}
});
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_googlepay.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_googlepay.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/klarna.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_klarna.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_klarna.description;
}
});
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_mobilepay.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_mobilepay.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/paypal.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_paypal.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_paypal.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/quickpay.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_gateway.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_gateway.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/swish.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_swish.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_swish.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/trustly.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_trustly.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_trustly.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/viabill.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_viabill.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_viabill.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/vipps.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ define(
getPaymentLogo: function () {
return window.checkoutConfig.payment.quickpay_vipps.paymentLogo;
},
getDescription: function () {
return window.checkoutConfig.payment.quickpay_vipps.description;
}
});
}
);
3 changes: 3 additions & 0 deletions view/frontend/web/template/payment/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
</label>
</div>
<div class="payment-method-content">
<!-- ko if: getDescription() -->
<p data-bind="html: getDescription()"></p>
<!-- /ko -->
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
Expand Down

0 comments on commit 16c00a6

Please sign in to comment.