Skip to content

Commit

Permalink
Merge pull request #5 from woutse/master
Browse files Browse the repository at this point in the history
Added feature validation delay
  • Loading branch information
Wouter Jonker authored Oct 17, 2019
2 parents 6b7d095 + 49e943d commit fe8a283
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 9 deletions.
48 changes: 43 additions & 5 deletions paynlpaymentmethods/controllers/front/finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand All @@ -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);
Expand All @@ -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');
}

}
27 changes: 23 additions & 4 deletions paynlpaymentmethods/paynlpaymentmethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.');
Expand Down Expand Up @@ -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'));
Expand All @@ -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(
Expand All @@ -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'),
Expand Down Expand Up @@ -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
);
}
Expand Down
57 changes: 57 additions & 0 deletions paynlpaymentmethods/views/templates/front/waiting.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<html>
<head>
<title>Pay.nl</title>
<meta http-equiv="refresh" content="5; URL={url}{$extendUrl}">
<style>
* {
font-family: Verdana;
}
Html, body {
height: 100%;
margin: 0;
}
div {
display: block;
}
#inner {
position: relative;
box-sizing: border-box;
height: 60%;
margin-top: 2%;
width: 50%;
margin-left: -25%;
left: 50%;
border: 1px solid #CCC;
text-align: center;
padding: 1%;
padding-top: 10%;
min-height: 300px;
background-color: #e4e4e4;
}
img {
display: inline-block;
margin-bottom: 2%;
}
.footer {
position: absolute;
bottom: 2%;
font-size: 11px;
width: 100%;
text-align: center;
left: 0;
}
</style>
</head>

<body>
<div id="inner">
<a href="https://www.pay.nl" target="_blank">
<img src="https://static.pay.nl/generic/images/100x100/logo.png"></a><br>
Please wait while your order is being processed...<br>

<div class="footer">
Support? Please contact <a href="mailto:[email protected]?SUBJECT=Prestashop delay module, order:{$order}">[email protected]</a> | +31 (0)88-88 66666 | Pay.nl
</div>
</div>
</body>
</html>

0 comments on commit fe8a283

Please sign in to comment.