From 64a7c22832fa190c982f62d2f3255748164ba2d0 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 5 Jul 2023 16:16:41 +0200 Subject: [PATCH 1/6] Custom Exchange URL --- upload/Pay/Controller/Admin.php | 7 +++++-- upload/Pay/Controller/Payment.php | 4 ++++ .../admin/language/en-gb/extension/payment/paynl3.php | 4 ++++ .../admin/language/nl-nl/extension/payment/paynl3.php | 4 ++++ .../admin/view/template/extension/payment/paynl3.twig | 11 +++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/upload/Pay/Controller/Admin.php b/upload/Pay/Controller/Admin.php index 5a46815..741ffa9 100755 --- a/upload/Pay/Controller/Admin.php +++ b/upload/Pay/Controller/Admin.php @@ -62,7 +62,8 @@ public function index() 'payment_paynl_general_gateway' => trim($settings['payment_paynl_general_gateway']), 'payment_paynl_general_prefix' => $settings['payment_paynl_general_prefix'], 'payment_paynl_general_display_icon' => $settings['payment_paynl_general_display_icon'], - 'payment_paynl_general_icon_style' => $settings['payment_paynl_general_icon_style'] + 'payment_paynl_general_icon_style' => $settings['payment_paynl_general_icon_style'], + 'payment_paynl_general_custom_exchange_url' => $settings['payment_paynl_general_custom_exchange_url'] ); $this->model_setting_setting->editSetting('payment_paynl_general', $settingsGeneral); @@ -92,6 +93,7 @@ public function index() $data['gateway'] = $this->configGet('gateway'); $data['prefix'] = $this->configGet('prefix'); $data['icon_style'] = $this->configGet('icon_style'); + $data['custom_exchange_url'] = $this->configGet('custom_exchange_url'); $data['display_icon'] = $this->configGet('display_icon'); $data['text_edit'] = 'PAY. - ' . $this->_defaultLabel; $data['error_warning'] = ''; @@ -232,7 +234,8 @@ public function install() 'payment_paynl_general_gateway' => $this->config->get('payment_paynl_general_gateway'), 'payment_paynl_general_prefix' => 'Order ', 'payment_paynl_general_display_icon' => $this->config->get('payment_paynl_general_display_icon'), - 'payment_paynl_general_icon_style' => $this->config->get('payment_paynl_general_icon_style') + 'payment_paynl_general_icon_style' => $this->config->get('payment_paynl_general_icon_style'), + 'payment_paynl_general_custom_exchange_url' => $this->config->get('payment_paynl_general_custom_exchange_url') ); $this->model_setting_setting->editSetting('payment_paynl_general', $settingsGeneral); $this->model_setting_setting->editSetting('payment_' . $this->_paymentMethodName, $settings); diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index 45b4fa6..f614772 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -77,6 +77,10 @@ public function startTransaction() $returnUrl = $this->url->link('extension/payment/' . $this->_paymentMethodName . '/finish'); $exchangeUrl = $this->url->link('extension/payment/' . $this->_paymentMethodName . '/exchange'); + if (!empty($this->config->get('payment_paynl_general_custom_exchange_url'))) { + $exchangeUrl = trim($this->config->get('payment_paynl_general_custom_exchange_url')); + } + $apiStart->setFinishUrl($returnUrl); $apiStart->setExchangeUrl($exchangeUrl); diff --git a/upload/admin/language/en-gb/extension/payment/paynl3.php b/upload/admin/language/en-gb/extension/payment/paynl3.php index 0fa9c15..2c3710a 100755 --- a/upload/admin/language/en-gb/extension/payment/paynl3.php +++ b/upload/admin/language/en-gb/extension/payment/paynl3.php @@ -64,6 +64,10 @@ $_['text_classic'] = 'Classic'; $_['text_newest'] = 'Newest'; +$_['text_custom_exchange_url'] = 'Alternatieve Exchange URL'; +$_['text_custom_exchange_url_tooltip'] = 'Use your own exchange-handler. Requests will be send as GET.
+ Example: https://www.yourdomain.nl/exchange_handler?action=#action#&order_id=#order_id#'; + $_['text_testmode'] = 'Testmode'; $_['text_testmode_tooltip'] = 'Enable or disable test mode to test the exchanges between PAY. and your webshop'; diff --git a/upload/admin/language/nl-nl/extension/payment/paynl3.php b/upload/admin/language/nl-nl/extension/payment/paynl3.php index ddc7278..bcbd0c9 100755 --- a/upload/admin/language/nl-nl/extension/payment/paynl3.php +++ b/upload/admin/language/nl-nl/extension/payment/paynl3.php @@ -64,6 +64,10 @@ $_['text_classic'] = 'Klassiek'; $_['text_newest'] = 'Nieuwste'; +$_['text_custom_exchange_url'] = 'Alternatieve Exchange URL'; +$_['text_custom_exchange_url_tooltip'] = 'Gebruik je eigen exchange-handler. Requests zullen verzonden worden al een GET.
+ Voorbeeld: https://www.yourdomain.nl/exchange_handler?action=#action#&order_id=#order_id#'; + $_['text_testmode'] = 'Testmode'; $_['text_testmode_tooltip'] = 'Zet de testmode aan of uit om de exchanges te testen tussen PAY. en uw webshop'; diff --git a/upload/admin/view/template/extension/payment/paynl3.twig b/upload/admin/view/template/extension/payment/paynl3.twig index ce7041a..43f5eb4 100755 --- a/upload/admin/view/template/extension/payment/paynl3.twig +++ b/upload/admin/view/template/extension/payment/paynl3.twig @@ -135,6 +135,17 @@ +
+ +
+ +
+

{{ text_method_settings }}

From 81183b424006b09a64fc3577b4ed7894f01c3fc8 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 5 Jul 2023 16:51:04 +0200 Subject: [PATCH 2/6] PHPCS aanpassingen --- .github/linters/phpcs.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/linters/phpcs.xml b/.github/linters/phpcs.xml index c4113fe..34882c7 100644 --- a/.github/linters/phpcs.xml +++ b/.github/linters/phpcs.xml @@ -21,5 +21,9 @@ + + + + From 53096f569f9a1e870e54fc2deb511e18891c7c48 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 5 Jul 2023 16:54:44 +0200 Subject: [PATCH 3/6] Check aanpassingen --- upload/Pay/Controller/Admin.php | 42 ++++++++++++++++++--------- upload/Pay/Controller/Payment.php | 48 +++++++++++++++++++++++-------- 2 files changed, 65 insertions(+), 25 deletions(-) diff --git a/upload/Pay/Controller/Admin.php b/upload/Pay/Controller/Admin.php index 741ffa9..22e4f47 100755 --- a/upload/Pay/Controller/Admin.php +++ b/upload/Pay/Controller/Admin.php @@ -25,6 +25,9 @@ private function configGet($field) return $configValue; } + /** + * @return void + */ public function index() { $this->load->language('extension/payment/' . $this->_paymentMethodName); @@ -67,7 +70,7 @@ public function index() ); $this->model_setting_setting->editSetting('payment_paynl_general', $settingsGeneral); - foreach($settingsGeneral as $strField => $strvalue) { + foreach ($settingsGeneral as $strField => $strvalue) { $this->config->set($strField, $strvalue); } } @@ -122,7 +125,9 @@ public function index() $this->load->model('localisation/geo_zone'); $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - if (empty($data['label'])) $data['label'] = $this->_defaultLabel; + if (empty($data['label'])) { + $data['label'] = $this->_defaultLabel; + } $data['confirm_on_start'] = !isset($data['confirm_on_start']) ? 1 : $data['confirm_on_start']; $data['send_status_updates'] = !isset($data['send_status_updates']) ? '1' : $data['send_status_updates']; @@ -161,12 +166,19 @@ public function index() $this->response->setOutput($this->load->view('extension/payment/paynl3', $data)); } + /** + * @param $field + * @return null + */ private function getPost($field) { $postArr = $this->request->post; return isset($postArr[$field]) ? $postArr[$field] : null; } + /** + * @return boolean + */ public function validateGeneral() { $apiToken = $this->getPost('payment_paynl_general_apitoken'); @@ -178,7 +190,7 @@ public function validateGeneral() if (empty($serviceId)) { $this->error['serviceid'] = $this->language->get('error_no_serviceid'); - }elseif (empty($apiToken)) { + } elseif (empty($apiToken)) { $this->error['apitoken'] = $this->language->get('error_no_apitoken'); } else { try { @@ -187,7 +199,6 @@ public function validateGeneral() $gateway = (!empty($reqGateway) && substr($reqGateway, 0, 4) == 'http') ? $reqGateway : null; $this->model_extension_payment_paynl3->refreshPaymentOptions($serviceId, $apiToken, $gateway); - } catch (Pay_Api_Exception $e) { $this->error['apitoken'] = $this->language->get('error_api_error') . $e->getMessage(); } catch (Pay_Exception $e) { @@ -200,9 +211,12 @@ public function validateGeneral() return empty($this->error); } + /** + * @return boolean + */ public function validatePaymentMethod() { - try { + try { $this->load->model('extension/payment/paynl3'); $paymentOption = $this->model_extension_payment_paynl3->getPaymentOption($this->_paymentOptionId); $status = $this->request->post['payment_' . $this->_paymentMethodName . '_status']; @@ -219,6 +233,9 @@ public function validatePaymentMethod() } } + /** + * @return void + */ public function install() { $this->load->model('extension/payment/paynl3'); @@ -226,20 +243,19 @@ public function install() $this->model_extension_payment_paynl3->createTables(); if ($this->config->get('payment_paynl_general_prefix') == null) { $this->load->model('setting/setting'); - $settings = $this->model_setting_setting->getSetting('payment_' . $this->_paymentMethodName); + $settings = $this->model_setting_setting->getSetting('payment_' . $this->_paymentMethodName); $settingsGeneral = array( - 'payment_paynl_general_apitoken' => $this->config->get('payment_paynl_general_apitoken'), - 'payment_paynl_general_serviceid' => $this->config->get('payment_paynl_general_serviceid'), - 'payment_paynl_general_testmode' => $this->config->get('payment_paynl_general_testmode'), - 'payment_paynl_general_gateway' => $this->config->get('payment_paynl_general_gateway'), + 'payment_paynl_general_apitoken' => $this->config->get('payment_paynl_general_apitoken'), + 'payment_paynl_general_serviceid' => $this->config->get('payment_paynl_general_serviceid'), + 'payment_paynl_general_testmode' => $this->config->get('payment_paynl_general_testmode'), + 'payment_paynl_general_gateway' => $this->config->get('payment_paynl_general_gateway'), 'payment_paynl_general_prefix' => 'Order ', - 'payment_paynl_general_display_icon' => $this->config->get('payment_paynl_general_display_icon'), + 'payment_paynl_general_display_icon' => $this->config->get('payment_paynl_general_display_icon'), 'payment_paynl_general_icon_style' => $this->config->get('payment_paynl_general_icon_style'), 'payment_paynl_general_custom_exchange_url' => $this->config->get('payment_paynl_general_custom_exchange_url') - ); + ); $this->model_setting_setting->editSetting('payment_paynl_general', $settingsGeneral); $this->model_setting_setting->editSetting('payment_' . $this->_paymentMethodName, $settings); } } - } diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index f614772..cd23bda 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -6,6 +6,9 @@ class Pay_Controller_Payment extends Controller protected $_paymentMethodName; protected $data = array(); + /** + * @return mixed + */ public function index() { $this->load->language('extension/payment/paynl3'); @@ -15,7 +18,7 @@ public function index() $this->data['button_confirm'] = $this->language->get('button_confirm'); $this->data['button_loading'] = $this->language->get('text_loading'); - $this->data['paymentMethodName'] = $this->_paymentMethodName; + $this->data['paymentMethodName'] = $this->_paymentMethodName; // paymentoption ophalen $this->load->model('extension/payment/' . $this->_paymentMethodName); @@ -50,9 +53,11 @@ public function index() $this->data['terms'] = ''; return $this->load->view('payment/paynl3', $this->data); - } + /** + * @return void + */ public function startTransaction() { $this->load->model('extension/payment/' . $this->_paymentMethodName); @@ -161,14 +166,22 @@ public function startTransaction() //Producten toevoegen foreach ($this->cart->getProducts() as $product) { - $priceWithTax = $this->tax->calculate($product['price'] * $currency_value, - $product['tax_class_id'], $this->config->get('config_tax')); + $priceWithTax = $this->tax->calculate( + $product['price'] * $currency_value, + $product['tax_class_id'], + $this->config->get('config_tax') + ); $tax = $priceWithTax - ($product['price'] * $currency_value); $price = round($priceWithTax * 100); - $apiStart->addProduct($product['product_id'], $product['name'], - $price, $product['quantity'], Pay_Helper::calculateTaxClass($priceWithTax, $tax)); + $apiStart->addProduct( + $product['product_id'], + $product['name'], + $price, + $product['quantity'], + Pay_Helper::calculateTaxClass($priceWithTax, $tax) + ); } $taxes = $this->cart->getTaxes(); @@ -203,7 +216,7 @@ public function startTransaction() $totalIncl = $totalIncl * $currency_value; $total_row_tax = $total_row_tax * $currency_value; - switch($total_row['code']){ + switch ($total_row['code']) { case 'shipping': $type = "SHIPPING"; break; @@ -213,7 +226,7 @@ public function startTransaction() } $apiStart->addProduct($total_row['code'], $total_row['title'], round($totalIncl * 100), 1, Pay_Helper::calculateTaxClass($totalIncl, $total_row_tax), $type); - } + } } $postData = $apiStart->getPostData(); @@ -222,9 +235,14 @@ public function startTransaction() //transactie is aangemaakt, nu loggen $modelName = 'model_extension_payment_' . $this->_paymentMethodName; - $this->$modelName->addTransaction($result['transaction']['transactionId'], - $order_info['order_id'], $this->_paymentOptionId, $amount, - $postData, $optionSub); + $this->$modelName->addTransaction( + $result['transaction']['transactionId'], + $order_info['order_id'], + $this->_paymentOptionId, + $amount, + $postData, + $optionSub + ); $message = 'PAY. Transactie aangemaakt. TransactieId: ' . $result['transaction']['transactionId'] . ' .
'; @@ -245,6 +263,9 @@ public function startTransaction() die(json_encode($response)); } + /** + * @return void + */ public function finish() { $this->load->model('extension/payment/' . $this->_paymentMethodName); @@ -266,7 +287,7 @@ public function finish() $action = $this->request->get['orderStatusId']; if ($action == -90) { $this->session->data['error'] = $this->language->get('text_cancel'); - } else if ($action == -63) { + } elseif ($action == -63) { $this->session->data['error'] = $this->language->get('text_denied'); } @@ -275,6 +296,9 @@ public function finish() die(); } + /** + * @return void + */ public function exchange() { $this->load->model('extension/payment/' . $this->_paymentMethodName); From 5bb570e7985d2d0d1e4334e4aacf3a04b3e7b911 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 5 Jul 2023 16:57:45 +0200 Subject: [PATCH 4/6] Laatste check --- upload/Pay/Controller/Payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index cd23bda..ca05af1 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -45,7 +45,7 @@ public function index() if (!empty($this->config->get('payment_' . $this->_paymentMethodName . '_vat')) && strlen($company) > 0) { $this->data['vat'] = $this->config->get('payment_' . $this->_paymentMethodName . '_vat'); } - + if (!empty($this->config->get('payment_' . $this->_paymentMethodName . '_dob'))) { $this->data['dob'] = $this->config->get('payment_' . $this->_paymentMethodName . '_dob'); } From e8632c36ab4253fae74eae78bd1fe194674948d8 Mon Sep 17 00:00:00 2001 From: Anne Date: Thu, 6 Jul 2023 14:41:48 +0200 Subject: [PATCH 5/6] HTML decode --- upload/Pay/Controller/Payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index ca05af1..878178b 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -83,7 +83,7 @@ public function startTransaction() $exchangeUrl = $this->url->link('extension/payment/' . $this->_paymentMethodName . '/exchange'); if (!empty($this->config->get('payment_paynl_general_custom_exchange_url'))) { - $exchangeUrl = trim($this->config->get('payment_paynl_general_custom_exchange_url')); + $exchangeUrl = trim(htmlspecialchars_decode($this->config->get('payment_paynl_general_custom_exchange_url'))); } $apiStart->setFinishUrl($returnUrl); From 6f4e3ca387c180317aea831d7c7622ca65d275c9 Mon Sep 17 00:00:00 2001 From: Wouter Jonker Date: Mon, 10 Jul 2023 12:26:14 +0200 Subject: [PATCH 6/6] Update Payment.php --- upload/Pay/Controller/Payment.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index 878178b..8a040bd 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -80,16 +80,16 @@ public function startTransaction() } $returnUrl = $this->url->link('extension/payment/' . $this->_paymentMethodName . '/finish'); - $exchangeUrl = $this->url->link('extension/payment/' . $this->_paymentMethodName . '/exchange'); + $customExchangeUrl = $this->config->get('payment_paynl_general_custom_exchange_url'); + $customExchangeUrl = is_null($customExchangeUrl) ? '' : trim($customExchangeUrl); - if (!empty($this->config->get('payment_paynl_general_custom_exchange_url'))) { - $exchangeUrl = trim(htmlspecialchars_decode($this->config->get('payment_paynl_general_custom_exchange_url'))); + if (!empty($customExchangeUrl)) { + $exchangeUrl = htmlspecialchars_decode($customExchangeUrl); } $apiStart->setFinishUrl($returnUrl); $apiStart->setExchangeUrl($exchangeUrl); - $apiStart->setPaymentOptionId($this->_paymentOptionId); $amount = round($order_info['total'] * 100 * $currency_value); $apiStart->setAmount($amount);