diff --git a/Controller/Checkout/Redirect.php b/Controller/Checkout/Redirect.php
index b5a0589c..8a930e5c 100644
--- a/Controller/Checkout/Redirect.php
+++ b/Controller/Checkout/Redirect.php
@@ -96,11 +96,12 @@ public function execute()
$methodInstance = $this->paymentHelper->getMethodInstance($method);
if ($methodInstance instanceof \Paynl\Payment\Model\Paymentmethod\Paymentmethod) {
+ $this->_logger->notice('PAY.: Start new payment for order ' . $order->getId());
$redirectUrl = $methodInstance->startTransaction($order);
$this->getResponse()->setNoCacheHeaders();
$this->getResponse()->setRedirect($redirectUrl);
} else {
- throw new Error('Method is not a paynl payment method');
+ throw new Error('PAY.: Method is not a paynl payment method');
}
} catch (\Exception $e) {
diff --git a/Model/Config.php b/Model/Config.php
index c9d76e9e..8ce08c44 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -24,6 +24,11 @@ public function __construct(
$this->store = $store;
}
+ public function getVersion()
+ {
+ return '1.5.6';
+ }
+
/**
* @param Store $store
*/
diff --git a/Model/Config/Source/showKvkOptions.php b/Model/Config/Source/showKvkOptions.php
new file mode 100644
index 00000000..038612fa
--- /dev/null
+++ b/Model/Config/Source/showKvkOptions.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 79c1a6f4..dfe1ff3a 100644
--- a/Model/ConfigProvider.php
+++ b/Model/ConfigProvider.php
@@ -108,7 +108,7 @@ public function getConfig()
$config['payment']['instructions'][$code] = $this->getInstructions($code);
$config['payment']['banks'][$code] = $this->getBanks($code);
$config['payment']['icon'][$code] = $this->getIcon($code);
-
+ $config['payment']['showkvk'][$code] = $this->getKVK($code);
}
}
@@ -132,6 +132,11 @@ protected function getBanks($code)
return $this->methods[$code]->getBanks();
}
+ protected function getKVK($code)
+ {
+ return $this->methods[$code]->getKVK();
+ }
+
/**
* Get payment method icon
*
diff --git a/Model/Paymentmethod/Billink.php b/Model/Paymentmethod/Billink.php
index 8ccab65a..9fd2060b 100644
--- a/Model/Paymentmethod/Billink.php
+++ b/Model/Paymentmethod/Billink.php
@@ -1,12 +1,14 @@
*/
@@ -18,4 +20,47 @@ protected function getDefaultPaymentOptionId()
{
return 1672;
}
+
+ public function getKVK()
+ {
+ return $this->_scopeConfig->getValue('payment/paynl_payment_billink/showkvk', 'store');
+ }
+
+ public function assignData(\Magento\Framework\DataObject $data)
+ {
+ parent::assignData($data);
+
+ if (is_array($data))
+ {
+ $this->getInfoInstance()->setAdditionalInformation('kvknummer', $data['kvknummer']);
+ } elseif ($data instanceof \Magento\Framework\DataObject)
+ {
+
+ $additional_data = $data->getAdditionalData();
+
+ if (isset($additional_data['kvknummer'])) {
+ $this->getInfoInstance()->setAdditionalInformation('kvknummer', $additional_data['kvknummer']);
+ }
+
+ if (isset($additional_data['billink_agree'])) {
+ $this->getInfoInstance()->setAdditionalInformation('billink_agree', $additional_data['billink_agree']);
+ }
+
+ }
+ return $this;
+ }
+
+
+ /**
+ * @return \Magento\Framework\App\CacheInterface
+ */
+ private function getCache()
+ {
+ /** @var \Magento\Framework\ObjectManagerInterface $om */
+ $om = \Magento\Framework\App\ObjectManager::getInstance();
+ /** @var \Magento\Framework\App\CacheInterface $cache */
+ $cache = $om->get('Magento\Framework\App\CacheInterface');
+ return $cache;
+ }
+
}
\ No newline at end of file
diff --git a/Model/Paymentmethod/PaymentMethod.php b/Model/Paymentmethod/PaymentMethod.php
index 2e541804..0ebbb14d 100644
--- a/Model/Paymentmethod/PaymentMethod.php
+++ b/Model/Paymentmethod/PaymentMethod.php
@@ -111,6 +111,11 @@ public function getBanks()
return [];
}
+ public function getKVK()
+ {
+ return [];
+ }
+
public function initialize($paymentAction, $stateObject)
{
$status = $this->getConfigData('order_status');
@@ -189,6 +194,9 @@ protected function doStartTransaction(Order $order)
$additionalData = $order->getPayment()->getAdditionalInformation();
$bankId = null;
$expireDate = null;
+ if (isset($additionalData['kvknummer']) && is_numeric($additionalData['kvknummer'])) {
+ $kvknummer = $additionalData['kvknummer'];
+ }
if (isset($additionalData['bank_id']) && is_numeric($additionalData['bank_id'])) {
$bankId = $additionalData['bank_id'];
}
@@ -237,6 +245,19 @@ protected function doStartTransaction(Order $order)
'emailAddress' => $arrBillingAddress['email'],
);
+ if (isset($arrBillingAddress['company']) && !empty($arrBillingAddress['company'])) {
+ $enduser['company']['name'] = $arrBillingAddress['company'];
+ $enduser['company']['countryCode'] = $arrBillingAddress['country_id'];
+ }
+
+ if (isset($kvknummer) && !empty($kvknummer)) {
+ $enduser['company']['cocNumber'] = $kvknummer;
+ }
+
+ if (isset($arrBillingAddress['vat_id']) && !empty($arrBillingAddress['vat_id'])) {
+ $enduser['company']['vatNumber'] = $arrBillingAddress['vat_id'];
+ }
+
$invoiceAddress = array(
'initials' => $strBillingFirstName,
'lastName' => $arrBillingAddress['lastname']
@@ -249,6 +270,9 @@ protected function doStartTransaction(Order $order)
$invoiceAddress['city'] = $arrBillingAddress['city'];
$invoiceAddress['country'] = $arrBillingAddress['country_id'];
+ if (isset($arrShippingAddress['vat_id']) && !empty($arrShippingAddress['vat_id'])) {
+ $enduser['company']['vatNumber'] = $arrShippingAddress['vat_id'];
+ }
}
$arrShippingAddress = $order->getShippingAddress();
@@ -289,7 +313,7 @@ protected function doStartTransaction(Order $order)
'extra3' => $order->getEntityId(),
'exchangeUrl' => $exchangeUrl,
'currency' => $currency,
- 'object' => 'magento2 1.5.5',
+ 'object' => 'magento2 ' . $this->paynlConfig->getVersion(),
);
if (isset($shippingAddress)) {
$data['address'] = $shippingAddress;
diff --git a/composer.json b/composer.json
index 67fe4f2a..919a3f00 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "paynl/magento2-plugin",
"description": "Pay.nl Magento2 Payment methods",
"type": "magento2-module",
- "version": "1.5.5",
+ "version": "1.5.6",
"require": {
"magento/module-sales": "100 - 103",
"magento/module-payment": "100 - 103",
diff --git a/etc/adminhtml/paymentmethods/billink.xml b/etc/adminhtml/paymentmethods/billink.xml
index f90e19dc..ec8b71fc 100644
--- a/etc/adminhtml/paymentmethods/billink.xml
+++ b/etc/adminhtml/paymentmethods/billink.xml
@@ -9,6 +9,15 @@
Paynl\Payment\Model\Config\Source\Available\Billink
payment/paynl_payment_billink/active
+
+
+ Paynl\Payment\Model\Config\Source\showKvkOptions
+
+ 1
+
+ payment/paynl_payment_billink/showkvk
+
+
diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js
index 98bec3bf..09d29623 100644
--- a/view/frontend/web/js/view/payment/method-renderer.js
+++ b/view/frontend/web/js/view/payment/method-renderer.js
@@ -11,12 +11,13 @@ define(
var defaultComponent = 'Paynl_Payment/js/view/payment/method-renderer/default';
var idealComponent = 'Paynl_Payment/js/view/payment/method-renderer/ideal';
+ var billinkComponent = 'Paynl_Payment/js/view/payment/method-renderer/billink';
var methods = [
{type: 'paynl_payment_afterpay', component: defaultComponent},
{type: 'paynl_payment_alipay', component: defaultComponent},
{type: 'paynl_payment_amex', component: defaultComponent},
- {type: 'paynl_payment_billink', component: defaultComponent},
+ {type: 'paynl_payment_billink', component: billinkComponent},
{type: 'paynl_payment_capayable', component: defaultComponent},
{type: 'paynl_payment_capayable_gespreid', component: defaultComponent},
{type: 'paynl_payment_cartasi', component: defaultComponent},
diff --git a/view/frontend/web/js/view/payment/method-renderer/billink.js b/view/frontend/web/js/view/payment/method-renderer/billink.js
new file mode 100644
index 00000000..57d97ff9
--- /dev/null
+++ b/view/frontend/web/js/view/payment/method-renderer/billink.js
@@ -0,0 +1,76 @@
+/*browser:true*/
+/*global define*/
+define(
+ [
+ 'jquery',
+ 'Magento_Checkout/js/view/payment/default',
+ 'mage/url',
+ 'Magento_Checkout/js/action/place-order'
+ ],
+ function ($, Component, url, placeOrderAction) {
+ 'use strict';
+ return Component.extend({
+ defaults: {
+ template: 'Paynl_Payment/payment/billink'
+ },
+ kvknummer: null,
+ billink_agree: null,
+ showKVK: function () {
+ return this.getKVK() > 0;
+ },
+ getKVK: function () {
+ return window.checkoutConfig.payment.showkvk[this.item.method];
+ },
+ /**
+ * Get payment method data
+ */
+ getData: function () {
+ return {
+ 'method': this.item.method,
+ 'po_number': null,
+ 'additional_data': {
+ "kvknummer": this.kvknummer,
+ "billink_agree": this.billink_agree
+ }
+ };
+ },
+ getInstructions: function () {
+ return window.checkoutConfig.payment.instructions[this.item.method];
+ },
+ getPaymentIcon: function () {
+ return window.checkoutConfig.payment.icon[this.item.method];
+ },
+ placeOrder: function (data, event) {
+ var placeOrder;
+ var showingKVK = this.getKVK() == 2;
+
+ if (showingKVK) {
+ if (this.billink_agree != true) {
+ alert('U dient eerst akkoord te gaan met de betalingsvoorwaarden van Billink.');
+ return false;
+ }
+ if (this.kvknummer == null || this.kvknummer.length < 8) {
+ alert('Voer een geldig KVK nummer in.');
+ return false;
+ }
+ }
+
+ if (event) {
+ event.preventDefault();
+ }
+
+ this.isPlaceOrderActionAllowed(false);
+ placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
+
+ $.when(placeOrder).fail(function () {
+ this.isPlaceOrderActionAllowed(true);
+ }.bind(this)).done(this.afterPlaceOrder.bind(this));
+
+ return true;
+ },
+ afterPlaceOrder: function () {
+ window.location.replace(url.build('/paynl/checkout/redirect?nocache=' + (new Date().getTime())));
+ },
+ });
+ }
+);
\ No newline at end of file
diff --git a/view/frontend/web/template/payment/billink.html b/view/frontend/web/template/payment/billink.html
new file mode 100644
index 00000000..bf984bdd
--- /dev/null
+++ b/view/frontend/web/template/payment/billink.html
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file