From 1861411fce402c9e9f8366c6ed085137f16c6331 Mon Sep 17 00:00:00 2001 From: Kevin Verschoor Date: Fri, 17 Apr 2020 09:38:34 +0200 Subject: [PATCH 1/4] Add DOB field to Billink --- Model/Config/Source/showDobOptions.php | 43 +++++++++++++++++++ Model/ConfigProvider.php | 8 +++- Model/Paymentmethod/Billink.php | 12 +++++- Model/Paymentmethod/PaymentMethod.php | 7 ++- etc/adminhtml/paymentmethods/billink.xml | 9 ++++ .../view/payment/method-renderer/billink.js | 24 ++++++++++- .../web/template/payment/billink.html | 13 ++++-- 7 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 Model/Config/Source/showDobOptions.php diff --git a/Model/Config/Source/showDobOptions.php b/Model/Config/Source/showDobOptions.php new file mode 100644 index 00000000..278c4adf --- /dev/null +++ b/Model/Config/Source/showDobOptions.php @@ -0,0 +1,43 @@ +toArray(); + + $arrResult = []; + foreach ($arrOptions as $value => $label) { + $arrResult[] = ['value' => $value, 'label' => $label]; + } + return $arrResult; + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + return [ + '0' => __('No'), + '1' => __('Yes, as optional'), + '2' => __('Yes, as required'), + ]; + } + +} diff --git a/Model/ConfigProvider.php b/Model/ConfigProvider.php index 3841baa4..2f79ada6 100644 --- a/Model/ConfigProvider.php +++ b/Model/ConfigProvider.php @@ -1,6 +1,6 @@ getBanks($code); $config['payment']['icon'][$code] = $this->getIcon($code); $config['payment']['showkvk'][$code] = $this->getKVK($code); + $config['payment']['dob'][$code] = $this->getDOB($code); } } @@ -139,6 +140,11 @@ protected function getKVK($code) return $this->methods[$code]->getKVK(); } + protected function getDOB($code) + { + return $this->methods[$code]->getDOB(); + } + /** * Get payment method icon * diff --git a/Model/Paymentmethod/Billink.php b/Model/Paymentmethod/Billink.php index 04a03e96..a0ffe8c6 100644 --- a/Model/Paymentmethod/Billink.php +++ b/Model/Paymentmethod/Billink.php @@ -1,6 +1,6 @@ _scopeConfig->getValue('payment/paynl_payment_billink/showkvk', 'store'); } + public function getDOB() + { + return $this->_scopeConfig->getValue('payment/paynl_payment_billink/showdob', 'store'); + } + public function assignData(\Magento\Framework\DataObject $data) { parent::assignData($data); @@ -33,6 +38,7 @@ public function assignData(\Magento\Framework\DataObject $data) if (is_array($data)) { $this->getInfoInstance()->setAdditionalInformation('kvknummer', $data['kvknummer']); + $this->getInfoInstance()->setAdditionalInformation('dob', $data['dob']); } elseif ($data instanceof \Magento\Framework\DataObject) { @@ -46,6 +52,10 @@ public function assignData(\Magento\Framework\DataObject $data) $this->getInfoInstance()->setAdditionalInformation('billink_agree', $additional_data['billink_agree']); } + if (isset($additional_data['dob'])) { + $this->getInfoInstance()->setAdditionalInformation('dob', $additional_data['dob']); + } + } return $this; } diff --git a/Model/Paymentmethod/PaymentMethod.php b/Model/Paymentmethod/PaymentMethod.php index 3f8773d2..9b9c3f83 100644 --- a/Model/Paymentmethod/PaymentMethod.php +++ b/Model/Paymentmethod/PaymentMethod.php @@ -1,6 +1,6 @@ getConfigData('order_status'); diff --git a/etc/adminhtml/paymentmethods/billink.xml b/etc/adminhtml/paymentmethods/billink.xml index ec8b71fc..aee2e0ce 100644 --- a/etc/adminhtml/paymentmethods/billink.xml +++ b/etc/adminhtml/paymentmethods/billink.xml @@ -18,6 +18,15 @@ payment/paynl_payment_billink/showkvk + + + Paynl\Payment\Model\Config\Source\showDobOptions + + 1 + + payment/paynl_payment_billink/showdob + + diff --git a/view/frontend/web/js/view/payment/method-renderer/billink.js b/view/frontend/web/js/view/payment/method-renderer/billink.js index 57d97ff9..6ec96f14 100644 --- a/view/frontend/web/js/view/payment/method-renderer/billink.js +++ b/view/frontend/web/js/view/payment/method-renderer/billink.js @@ -14,13 +14,26 @@ define( template: 'Paynl_Payment/payment/billink' }, kvknummer: null, + dateofbirth: null, billink_agree: null, - showKVK: function () { + showKVK: function () { return this.getKVK() > 0; }, getKVK: function () { return window.checkoutConfig.payment.showkvk[this.item.method]; }, + showDOB: function () { + return this.getDOB() > 0; + }, + getDOB: function () { + return window.checkoutConfig.payment.showdob[this.item.method]; + }, + showKVKDOB: function () { + return this.getDOB() > 0; + }, + getKVKDOB: function () { + return (this.getDOB() > 0 && this.getKVK() > 0); + }, /** * Get payment method data */ @@ -30,6 +43,7 @@ define( 'po_number': null, 'additional_data': { "kvknummer": this.kvknummer, + "dob": this.dob, "billink_agree": this.billink_agree } }; @@ -43,7 +57,7 @@ define( placeOrder: function (data, event) { var placeOrder; var showingKVK = this.getKVK() == 2; - + var showingDOB = this.getDOB() == 2; if (showingKVK) { if (this.billink_agree != true) { alert('U dient eerst akkoord te gaan met de betalingsvoorwaarden van Billink.'); @@ -54,6 +68,12 @@ define( return false; } } + if (showingDOB) { + if (this.dob == null || this.dob.length < 8) { + alert('Voer een geldig geboortedatum in.'); + return false; + } + } if (event) { event.preventDefault(); diff --git a/view/frontend/web/template/payment/billink.html b/view/frontend/web/template/payment/billink.html index bf984bdd..c35b68ef 100644 --- a/view/frontend/web/template/payment/billink.html +++ b/view/frontend/web/template/payment/billink.html @@ -21,15 +21,22 @@

+
+ + +
+
+
+
- - -
+ +
betalingsvoorwaarden
+