From 48350d192f59114f52515767f915f3d516b5001c Mon Sep 17 00:00:00 2001 From: woutse Date: Mon, 14 Oct 2019 12:25:09 +0200 Subject: [PATCH 1/2] Added new feauture validation delay --- .../controllers/front/finish.php | 48 ++++++++++++++-- paynlpaymentmethods/paynlpaymentmethods.php | 27 +++++++-- .../views/templates/front/waiting.tpl | 57 +++++++++++++++++++ 3 files changed, 123 insertions(+), 9 deletions(-) create mode 100644 paynlpaymentmethods/views/templates/front/waiting.tpl diff --git a/paynlpaymentmethods/controllers/front/finish.php b/paynlpaymentmethods/controllers/front/finish.php index fef1327..d154577 100644 --- a/paynlpaymentmethods/controllers/front/finish.php +++ b/paynlpaymentmethods/controllers/front/finish.php @@ -29,12 +29,25 @@ */ class PaynlPaymentMethodsFinishModuleFrontController extends ModuleFrontController { - /** - * @see FrontController::postProcess() - */ + + private $order = null; + private $payOrderId = null; + private $orderStatusId = null; + private $paymentSessionId = null; + /** + * @see FrontController::postProcess() + */ public function postProcess() { - $transactionId = $_REQUEST['orderId']; + $transactionId = $_REQUEST['orderId']; + + $iAttempt = Tools::getValue('attempt'); + + $bValidationDelay = Configuration::get('PAYNL_VALIDATION_DELAY') == 1; + + $this->payOrderId = $transactionId; + $this->orderStatusId = Tools::getValue('orderStatusId'); + $this->paymentSessionId = Tools::getValue('paymentSessionId'); $module = $this->module; /** @@ -56,8 +69,12 @@ public function postProcess() $customer = new Customer($cart->id_customer); $slow = ''; + if (!$transaction->isPaid()) { $slow = '&slowvalidation=1'; + if($bValidationDelay == 1 && $iAttempt < 20) { + return; + } } unset($this->context->cart); @@ -66,11 +83,32 @@ public function postProcess() $cartId = $transaction->getExtra1(); $orderId = Order::getIdByCartId($cartId); + $this->order = $orderId; + Tools::redirect('index.php?controller=order-confirmation'.$slow.'&id_cart=' . $cartId . '&id_module=' . $this->module->id . '&id_order=' . $orderId . '&key=' . $customer->secure_key); + } else { // naar checkout Tools::redirect('index.php?controller=order&step=1'); } + } + + public function initContent() + { + $iAttempt = Tools::getValue('attempt'); + + if (empty($iAttempt)) { + $iAttempt = 0; } -} + + $iAttempt += 1; + $url = 'module/paynlpaymentmethods/finish?orderId=' . $this->payOrderId . + '&orderStatusId=' . $this->orderStatusId . + '&paymentSessionId=' . $this->paymentSessionId . '&utm_nooverride=1&attempt=' . $iAttempt; + + $this->context->smarty->assign(array('order' => $this->payOrderId, 'extendUrl' => $url)); + $this->setTemplate('module:paynlpaymentmethods/views/templates/front/waiting.tpl'); + } + +} \ No newline at end of file diff --git a/paynlpaymentmethods/paynlpaymentmethods.php b/paynlpaymentmethods/paynlpaymentmethods.php index ab24896..bcd0646 100644 --- a/paynlpaymentmethods/paynlpaymentmethods.php +++ b/paynlpaymentmethods/paynlpaymentmethods.php @@ -51,7 +51,7 @@ public function __construct() { $this->name = 'paynlpaymentmethods'; $this->tab = 'payments_gateways'; - $this->version = '4.2.5'; + $this->version = '4.2.6'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->author = 'Pay.nl'; @@ -69,7 +69,7 @@ public function __construct() $this->statusRefund = Configuration::get('PS_OS_REFUND'); $this->displayName = $this->l('Pay.nl'); - $this->description = $this->l('Add many payment methods to you webshop'); + $this->description = $this->l('Add many payment methods to your webshop'); if (!count(Currency::checkPaymentCurrencies($this->id))) { $this->warning = $this->l('No currency has been set for this module.'); @@ -903,6 +903,7 @@ protected function _postProcess() Configuration::updateValue('PAYNL_API_TOKEN', Tools::getValue('PAYNL_API_TOKEN')); Configuration::updateValue('PAYNL_SERVICE_ID', Tools::getValue('PAYNL_SERVICE_ID')); Configuration::updateValue('PAYNL_TEST_MODE', Tools::getValue('PAYNL_TEST_MODE')); + Configuration::updateValue('PAYNL_VALIDATION_DELAY', Tools::getValue('PAYNL_VALIDATION_DELAY')); Configuration::updateValue('PAYNL_DESCRIPTION_PREFIX', Tools::getValue('PAYNL_DESCRIPTION_PREFIX')); Configuration::updateValue('PAYNL_PAYMENTMETHODS', Tools::getValue('PAYNL_PAYMENTMETHODS')); Configuration::updateValue('PAYNL_LANGUAGE', Tools::getValue('PAYNL_LANGUAGE')); @@ -915,7 +916,7 @@ public function renderAccountSettingsForm() $fields_form = array( 'form' => array( 'legend' => array( - 'title' => $this->l('Pay.nl Account Settings'), + 'title' => $this->l('Pay.nl Account Settings. Plugin version 4.2.6'), 'icon' => 'icon-envelope' ), 'input' => array( @@ -940,6 +941,24 @@ public function renderAccountSettingsForm() 'desc' => $this->l('A prefix added to the transaction description'), 'required' => false ), + array( + 'type' => 'switch', + 'label' => $this->l('Validation delay'), + 'name' => 'PAYNL_VALIDATION_DELAY', + 'desc' => $this->l('When payment is done, wait for Pay.nl to validate payment before redirecting to success page'), + 'values' => array( + array( + 'id' => 'validation_delay_on', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'validation_delay_off', + 'value' => 0, + 'label' => $this->l('Disabled') + ) + ), + ), array( 'type' => 'switch', 'label' => $this->l('Test mode'), @@ -1018,9 +1037,9 @@ public function getConfigFieldsValues() 'PAYNL_API_TOKEN' => Tools::getValue('PAYNL_API_TOKEN', Configuration::get('PAYNL_API_TOKEN')), 'PAYNL_SERVICE_ID' => Tools::getValue('PAYNL_SERVICE_ID', Configuration::get('PAYNL_SERVICE_ID')), 'PAYNL_TEST_MODE' => Tools::getValue('PAYNL_TEST_MODE', Configuration::get('PAYNL_TEST_MODE')), + 'PAYNL_VALIDATION_DELAY' => Tools::getValue('PAYNL_VALIDATION_DELAY', Configuration::get('PAYNL_VALIDATION_DELAY')), 'PAYNL_DESCRIPTION_PREFIX' => Tools::getValue('PAYNL_DESCRIPTION_PREFIX', Configuration::get('PAYNL_DESCRIPTION_PREFIX')), 'PAYNL_LANGUAGE' => Tools::getValue('PAYNL_LANGUAGE', Configuration::get('PAYNL_LANGUAGE')), - 'PAYNL_PAYMENTMETHODS' => $paymentMethods ); } diff --git a/paynlpaymentmethods/views/templates/front/waiting.tpl b/paynlpaymentmethods/views/templates/front/waiting.tpl new file mode 100644 index 0000000..96456f5 --- /dev/null +++ b/paynlpaymentmethods/views/templates/front/waiting.tpl @@ -0,0 +1,57 @@ + + + Pay.nl + + + + + +
+ +
+ Please wait while your order is being processed...
+ + +
+ + \ No newline at end of file From 49e943d97511b12c6b7644c7a6f6962905cdcd18 Mon Sep 17 00:00:00 2001 From: woutse Date: Mon, 14 Oct 2019 13:10:53 +0200 Subject: [PATCH 2/2] Added new feauture validation delay --- paynlpaymentmethods/views/templates/front/waiting.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paynlpaymentmethods/views/templates/front/waiting.tpl b/paynlpaymentmethods/views/templates/front/waiting.tpl index 96456f5..0048843 100644 --- a/paynlpaymentmethods/views/templates/front/waiting.tpl +++ b/paynlpaymentmethods/views/templates/front/waiting.tpl @@ -46,7 +46,7 @@
-
+
Please wait while your order is being processed...