diff --git a/controllers/front/chargeajax.php b/controllers/front/chargeajax.php index bd7a4c8..c9b0004 100644 --- a/controllers/front/chargeajax.php +++ b/controllers/front/chargeajax.php @@ -12,6 +12,7 @@ public function initContent() public function displayAjax() { $result = $this->module->charge(Tools::getValue("token_id"), Tools::getValue("installments")); //$_POST["token_id"], $_POST["installments"] + if($result->id) Configuration::updateValue($result->id,'generatedCulqi'); die(Tools::jsonEncode($result)); } @@ -20,8 +21,8 @@ public function displayAjaxOrder() { error_log('Actualizando orden'); $result = $this->module->updateOrder(Tools::getValue("order_id")); //$_POST["cart_id"] - + if($result->id) Configuration::updateValue($result->id,'generatedCulqi'); die(Tools::jsonEncode($result)); } -} +} \ No newline at end of file diff --git a/controllers/front/orderajax.php b/controllers/front/orderajax.php index da8a9df..9c002f9 100644 --- a/controllers/front/orderajax.php +++ b/controllers/front/orderajax.php @@ -13,6 +13,7 @@ public function displayAjax() { error_log('Actualizando orden'); $result = $this->module->updateOrder( Tools::getValue("order_id")); //$_POST["cart_id"] + if($result->id) Configuration::updateValue($result->id,'generatedCulqi'); die(Tools::jsonEncode($result)); } diff --git a/controllers/front/postpayment.php b/controllers/front/postpayment.php index 92f8d8c..1eb112d 100755 --- a/controllers/front/postpayment.php +++ b/controllers/front/postpayment.php @@ -10,6 +10,10 @@ public function initContent() $cart = $this->context->cart; $customer = new Customer($cart->id_customer); + + if(!Configuration::get(Tools::getValue('validation'))) die($this->l('Primero, debes pagar la order...')); + if(Configuration::get(Tools::getValue('validation')) !== 'generatedCulqi') die($this->l('Primero, debes pagar la orden... ')); + Configuration::deleteByName(Tools::getValue('validation')); $this->module->validateOrder((int)$cart->id, Configuration::get('CULQI_STATE_OK'), (float)$cart->getordertotal(true), 'Culqi', null, array(), (int)$cart->id_currency, false, $customer->secure_key); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int)$cart->id . '&id_module=' . (int)$this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key); diff --git a/controllers/front/postpendingpayment.php b/controllers/front/postpendingpayment.php index 187b5b9..3f273b8 100644 --- a/controllers/front/postpendingpayment.php +++ b/controllers/front/postpendingpayment.php @@ -10,6 +10,10 @@ public function initContent() $cart = $this->context->cart; $customer = new Customer($cart->id_customer); + + if(!Configuration::get(Tools::getValue('validation'))) die($this->l('Primero, debes pagar la order...')); + if(Configuration::get(Tools::getValue('validation')) !== 'generatedCulqi') die($this->l('Primero, debes pagar la orden... ')); + Configuration::deleteByName(Tools::getValue('validation')); $this->module->validateOrder((int)$cart->id, Configuration::get('CULQI_STATE_PENDING'), (float)$cart->getordertotal(true), 'Culqi', null, array(), (int)$cart->id_currency, false, $customer->secure_key); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int)$cart->id . '&id_module=' . (int)$this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key); diff --git a/views/templates/front/payment_execution.tpl b/views/templates/front/payment_execution.tpl index a78ce6a..d67cdc1 100755 --- a/views/templates/front/payment_execution.tpl +++ b/views/templates/front/payment_execution.tpl @@ -85,7 +85,7 @@ $('body').waitMe('hide'); showResult('green',result.outcome.user_message); Culqi.close(); - redirect(); + redirect(result.id); } if(result.object === 'error'){ $('body').waitMe('hide'); @@ -132,7 +132,7 @@ if(result.object === 'order'){ $('body').waitMe('hide'); console.log('Redirigiendo....'); - redirectPending(); + redirectPending(result.id); } if(result.object === 'error'){ $('body').waitMe('hide'); @@ -174,14 +174,14 @@ $('#showresultcontent').html(message); } - function redirect() { + function redirect(value) { var url = fnReplace("{/literal}{$link->getModuleLink('culqi', 'postpayment', [], true)|escape:'htmlall':'UTF-8'}{literal}"); - location.href = url; + location.href = url + '?validation=' + value; }; - function redirectPending() { + function redirectPending(value) { var url = fnReplace("{/literal}{$link->getModuleLink('culqi', 'postpendingpayment', [], true)|escape:'htmlall':'UTF-8'}{literal}"); - location.href = url; + location.href = url + '?validation=' + value; }; function fnReplace(url) { @@ -244,7 +244,7 @@ if(result.object === 'charge'){ $('body').waitMe('hide'); showResult('green',result.outcome.user_message); - redirect(); + redirect(result.id); } if(result.object === 'error'){ $('body').waitMe('hide'); @@ -276,9 +276,9 @@ $('#showresultcontent').html(message); } - function redirect() { + function redirect(value) { var url = fnReplace("{/literal}{$link->getModuleLink('culqi', 'postpayment', [], true)|escape:'htmlall':'UTF-8'}{literal}"); - location.href = url; + location.href = url + '?validation=' + value; }; function fnReplace(url) {