diff --git a/Model/Config.php b/Model/Config.php index 2d1bbd73..311f7b82 100755 --- a/Model/Config.php +++ b/Model/Config.php @@ -425,7 +425,12 @@ public function getIconUrl(string $methodCode) if (empty($brandId)) { $brandId = $this->brands[$methodCode]; } - return $this->resources->getViewFileUrl("Paynl_Payment::logos/" . $brandId . ".png"); + return $this->resources->getViewFileUrl( + "Paynl_Payment::logos/" . $brandId . ".png", + array( + 'area' => 'frontend' + ) + ); } /** @@ -434,7 +439,12 @@ public function getIconUrl(string $methodCode) */ public function getIconUrlIssuer(string $issuerId) { - return $this->resources->getViewFileUrl("Paynl_Payment::logos_issuers/qr-" . $issuerId . ".svg"); + return $this->resources->getViewFileUrl( + "Paynl_Payment::logos_issuers/qr-" . $issuerId . ".svg", + array( + 'area' => 'frontend' + ) + ); } /** diff --git a/Model/Paymentmethod/Ideal.php b/Model/Paymentmethod/Ideal.php index 87747195..0cd98071 100644 --- a/Model/Paymentmethod/Ideal.php +++ b/Model/Paymentmethod/Ideal.php @@ -2,20 +2,24 @@ namespace Paynl\Payment\Model\Paymentmethod; -use Paynl\Payment\Model\Config; - class Ideal extends PaymentMethod { - - const BANKSDISPLAYTYPE_DROPDOWN = 1; - const BANKSDISPLAYTYPE_LIST = 2; + public const BANKSDISPLAYTYPE_DROPDOWN = 1; + public const BANKSDISPLAYTYPE_LIST = 2; protected $_code = 'paynl_payment_ideal'; + /** + * @return integer + */ protected function getDefaultPaymentOptionId() { return 10; } + /** + * @param \Magento\Framework\DataObject $data + * @return object + */ public function assignData(\Magento\Framework\DataObject $data) { parent::assignData($data); @@ -32,18 +36,19 @@ public function assignData(\Magento\Framework\DataObject $data) return $this; } + /** + * @return integer + */ public function showPaymentOptions() { return $this->_scopeConfig->getValue('payment/' . $this->_code . '/bank_selection', 'store'); } + /** + * @return array + */ public function getPaymentOptions() { - $show_banks = $this->_scopeConfig->getValue('payment/' . $this->_code . '/bank_selection', 'store'); - if (!$show_banks) { - return []; - } - $cache = $this->getCache(); $store = $this->storeManager->getStore(); $storeId = $store->getId(); @@ -59,16 +64,9 @@ public function getPaymentOptions() $banks = \Paynl\Paymentmethods::getBanks($this->getPaymentOptionId()); $cache->save(json_encode($banks), $cacheName); } - if ($this->showPaymentOptions() != self::BANKSDISPLAYTYPE_LIST) { - array_unshift($banks, array( - 'id' => '', - 'name' => __('Choose your bank'), - 'visibleName' => __('Choose your bank') - )); - } else { - foreach ($banks as $key => $bank) { - $banks[$key]['logo'] = $this->paynlConfig->getIconUrlIssuer($bank['id']); - } + + foreach ($banks as $key => $bank) { + $banks[$key]['logo'] = $this->paynlConfig->getIconUrlIssuer($bank['id']); } return $banks; diff --git a/Model/Paymentmethod/Instore.php b/Model/Paymentmethod/Instore.php index b9f64db5..f21242a4 100644 --- a/Model/Paymentmethod/Instore.php +++ b/Model/Paymentmethod/Instore.php @@ -128,6 +128,19 @@ public function assignData(\Magento\Framework\DataObject $data) return $this; } + /** + * @return integer|mixed + */ + public function showPaymentOptions() + { + if (!empty($this->getDefaultPaymentOption()) && $this->getDefaultPaymentOption() != '0') { + if ($this->_scopeConfig->getValue('payment/' . $this->_code . '/hide_terminal_selection', 'store') == 1) { + return 0; + } + } + return 1; + } + /** * @return array|false|mixed * @throws \Magento\Framework\Exception\NoSuchEntityException @@ -167,23 +180,8 @@ public function getPaymentOptions() return false; } } - array_unshift($terminalsArr, [ - 'id' => '', - 'name' => __('Choose the pin terminal'), - 'visibleName' => __('Choose the pin terminal') - ]); - return $terminalsArr; - } - /** - * @return integer|mixed - */ - public function hidePaymentOptions() - { - if (!empty($this->getDefaultPaymentOption()) && $this->getDefaultPaymentOption() != '0') { - return $this->_scopeConfig->getValue('payment/' . $this->_code . '/hide_terminal_selection', 'store'); - } - return 0; + return $terminalsArr; } /** diff --git a/view/frontend/web/js/view/payment/method-renderer/default.js b/view/frontend/web/js/view/payment/method-renderer/default.js index 53a743e1..31922392 100755 --- a/view/frontend/web/js/view/payment/method-renderer/default.js +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -142,16 +142,28 @@ define( return (this.getDOB() > 0 && this.getKVK() > 0); }, showPaymentOptions: function () { - if (window.checkoutConfig.payment.hidepaymentoptions[this.item.method] == 1) { - return false; - } - return window.checkoutConfig.payment.paymentoptions[this.item.method].length > 0 && window.checkoutConfig.payment.showpaymentoptions[this.item.method] != 2; + return window.checkoutConfig.payment.paymentoptions[this.item.method].length > 0 && window.checkoutConfig.payment.showpaymentoptions[this.item.method] == 1; }, showPaymentOptionsList: function () { return window.checkoutConfig.payment.paymentoptions[this.item.method].length >= 1 && window.checkoutConfig.payment.showpaymentoptions[this.item.method] == 2; }, getPaymentOptions: function () { - return window.checkoutConfig.payment.paymentoptions[this.item.method]; + var paymentOptions = window.checkoutConfig.payment.paymentoptions[this.item.method]; + var message = null; + if (this.item.method == 'paynl_payment_ideal') { + message = $.mage.__('Choose your bank'); + } + if (this.item.method == 'paynl_payment_instore') { + message = $.mage.__('Choose the pin terminal'); + } + if (message && this.showPaymentOptions() === true) { + var paymentOption = []; + paymentOption['id'] = ''; + paymentOption['name'] = message; + paymentOption['visibleName'] = message; + paymentOptions.unshift(paymentOption); + } + return paymentOptions; }, getPaymentOptionsList: function(){ if(!this.showPaymentOptionsList){