Skip to content

Commit

Permalink
Merge pull request #99 from pagantis/INT-1067
Browse files Browse the repository at this point in the history
Int 1067
  • Loading branch information
rmarinleal authored Sep 22, 2020
2 parents 9f6e4cd + 88cb422 commit 79d04dd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>pagantis</name>
<displayName><![CDATA[Pagantis]]></displayName>
<version><![CDATA[8.6.7]]></version>
<version><![CDATA[8.6.8]]></version>
<description><![CDATA[Instant, easy and effective financial tool for your customers]]></description>
<author><![CDATA[Pagantis]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
25 changes: 22 additions & 3 deletions controllers/front/notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public function postProcess()
$thrownException = false;
$this->origin = ($this->isPost() || Tools::getValue('origin') === 'notification') ? 'Notification' : 'Order';
$this->requestId = rand(1, 999999999);

// Validations
try {
//Avoiding notifications via GET
if ($this->isGet() && $this->isNotification()) {
Expand All @@ -132,9 +134,7 @@ public function postProcess()
return $this->finishProcess(false);
}
$this->validateAmount();
if ($this->checkMerchantOrderStatus()) {
$this->processMerchantOrder();
}
$this->checkMerchantOrderStatus();
} catch (\Exception $exception) {
$thrownException = true;
$this->getMerchantOrderId();
Expand All @@ -148,6 +148,7 @@ public function postProcess()
return $this->cancelProcess($exception);
}

// Proccess Pagantis Order
try {
if (!$thrownException) {
$this->jsonResponse = new JsonSuccessResponse();
Expand All @@ -170,6 +171,24 @@ public function postProcess()
return $this->cancelProcess($exception);
}

// Process Merchant Order
try {
if (!$thrownException) {
$this->processMerchantOrder();
}
} catch (\Exception $exception) {
$thrownException = true;
$this->getMerchantOrderId();
$theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId;
if ($this->isPost()) {
$this->jsonResponse = new JsonExceptionResponse();
$this->jsonResponse->setMerchantOrderId($theId);
$this->jsonResponse->setPagantisOrderId($this->pagantisOrderId);
$this->jsonResponse->setException($exception);
}
return $this->cancelProcess($exception);
}

try {
$this->unblockConcurrency($this->merchantCartId);
} catch (\Exception $exception) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pagantis",
"version": "8.6.7",
"version": "8.6.8",
"description": "Pagantis integration in prestashop",
"main": "Gruntfile.js",
"dependencies": {},
Expand Down
25 changes: 12 additions & 13 deletions pagantis.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __construct()
{
$this->name = 'pagantis';
$this->tab = 'payments_gateways';
$this->version = '8.6.7';
$this->version = '8.6.8';
$this->author = 'Pagantis';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
Expand All @@ -125,16 +125,15 @@ public function __construct()
'Instant, easy and effective financial tool for your customers'
);

$sql_file = dirname(__FILE__).'/sql/install.sql';
$this->loadSQLFile($sql_file);

$this->checkEnvVariables();

$this->migrate();

$this->checkHooks();

$this->checkPromotionCategory();
$current_context = Context::getContext();
if (!is_null($current_context->controller) && $current_context->controller->controller_type != 'front') {
$sql_file = dirname(__FILE__).'/sql/install.sql';
$this->loadSQLFile($sql_file);
$this->checkEnvVariables();
$this->migrate();
$this->checkHooks();
$this->checkPromotionCategory();
}

parent::__construct();

Expand Down Expand Up @@ -896,15 +895,15 @@ public static function getExtraConfig($config = null, $product = "P4X", $default

if (is_null($product)) {
$sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1';
if ($results = Db::getInstance()->ExecuteS($sql)) {
if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) {
if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) {
return $results[0]['value'];
}
}
}

$sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($product) . '\' limit 1';
if ($results = Db::getInstance()->ExecuteS($sql)) {
if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) {
if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) {
$configs = json_decode($results[0]['value'], true);
$value = '';
Expand Down
10 changes: 10 additions & 0 deletions views/templates/hook/product-simulator-pagantis.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@
loadSimulator();
}, 2000);
}
window.PSSimulatorReloadAttempts = 0;
setInterval(function () {
if (!checkSimulatorContent()
&& typeof pgSDK.product_simulator != "undefined"
&& window.PSSimulatorReloadAttempts <= 5
) {
pgSDK.simulator.init(pgSDK.product_simulator);
window.PSSimulatorReloadAttempts = window.PSSimulatorReloadAttempts + 1;
}
}, 2000);
</script>
{if $PAGANTIS_IS_PROMOTED_PRODUCT == true}
<span class="pagantis-promotion ps_version_{$PAGANTIS_PS_VERSION|escape:'htmlall':'UTF-8'}" id="pagantis-promotion-extra">{$PAGANTIS_PROMOTION_EXTRA nofilter}</span>
Expand Down

0 comments on commit 79d04dd

Please sign in to comment.