From 43732149f4d5834b30341b6fdd8b5a5e44846ee6 Mon Sep 17 00:00:00 2001 From: JoseHCalderon <105760917+JoseHCalderon@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:58:46 -0500 Subject: [PATCH 1/2] installments --- config_es.xml | 2 +- culqi.php | 2 +- .../front/payment_execution_payme.tpl | 43 +++++++++++-------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/config_es.xml b/config_es.xml index 0b67938..8c98f90 100644 --- a/config_es.xml +++ b/config_es.xml @@ -2,7 +2,7 @@ culqi - + diff --git a/culqi.php b/culqi.php index 500dd00..e073166 100644 --- a/culqi.php +++ b/culqi.php @@ -4,7 +4,7 @@ if (!defined('_PS_VERSION_')) exit; -define('CULQI_PLUGIN_VERSION', '3.1.1'); +define('CULQI_PLUGIN_VERSION', '3.1.2'); define('URLAPI_INTEG', 'https://integ-panel.culqi.com'); define('URLAPI_PROD', 'https://panel.culqi.com'); diff --git a/views/templates/front/payment_execution_payme.tpl b/views/templates/front/payment_execution_payme.tpl index 92a270c..f93c937 100644 --- a/views/templates/front/payment_execution_payme.tpl +++ b/views/templates/front/payment_execution_payme.tpl @@ -93,19 +93,21 @@ const run_waitMe = (bg='rgba(0,0,0, 0.7)') => { $(document).ajaxComplete(function () { }); - var installments = (Culqi.token.metadata == undefined || Culqi.token.metadata.installments == undefined) ? 0 : Culqi.token.metadata.installments; + var payloadCharge = { + ajax: true, + action: 'displayAjax', + token_id: Culqi.token.id, + email: Culqi.token.email, + device: device, + parameters3DS: parameters3DS + }; + if (Culqi.token.metadata == undefined || Culqi.token.metadata.installments == undefined){ + payloadCharge.installments = Culqi.token.metadata.installments; + } $.ajax({ url: fnReplace("{/literal}{$link->getModuleLink('culqi', 'chargeajax', [], true)|escape:'htmlall':'UTF-8'}{literal}"), - data: { - ajax: true, - action: 'displayAjax', - token_id: Culqi.token.id, - installments: installments, - email: Culqi.token.email, - device: device, - parameters3DS: parameters3DS - }, + data: payloadCharge, type: "POST", dataType: 'json', success: function (data, textStatus, xhr) { @@ -441,17 +443,20 @@ const run_waitMe = (bg='rgba(0,0,0, 0.7)') => { $(document).ajaxComplete(function () { }); - var installments = (Culqi.token.metadata == undefined || Culqi.token.metadata.installments == undefined) ? 0 : Culqi.token.metadata.installments; + var payloadCharge = { + ajax: true, + action: 'displayAjax', + token_id: Culqi.token.id, + email: Culqi.token.email, + device: device + }; + if (Culqi.token.metadata == undefined || Culqi.token.metadata.installments == undefined){ + payloadCharge.installments = Culqi.token.metadata.installments; + } + $.ajax({ url: fnReplace("{/literal}{$link->getModuleLink('culqi', 'chargeajax', [], true)|escape:'htmlall':'UTF-8'}{literal}"), - data: { - ajax: true, - action: 'displayAjax', - token_id: Culqi.token.id, - installments: installments, - email: Culqi.token.email, - device: device - }, + data: payloadCharge, type: "POST", dataType: 'json', success: function (data, textStatus, xhr) { From f74bb9267d24f016479ed7122f2c699daf84c748 Mon Sep 17 00:00:00 2001 From: JoseHCalderon <105760917+JoseHCalderon@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:30:34 -0500 Subject: [PATCH 2/2] installments --- controllers/front/chargeajax.php | 3 +++ views/templates/front/payment_execution_payme.tpl | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/controllers/front/chargeajax.php b/controllers/front/chargeajax.php index 8832cc3..0a84d73 100644 --- a/controllers/front/chargeajax.php +++ b/controllers/front/chargeajax.php @@ -73,6 +73,9 @@ public function displayAjax() if (Tools::getValue("parameters3DS") !== FALSE) { $args_charge['authentication_3DS'] = Tools::getValue("parameters3DS"); } + if (Tools::getValue("installments") !== FALSE) { + $args_charge['installments'] = Tools::getValue("installments"); + } $culqi_charge = $culqi->Charges->create($args_charge); } catch (Exception $e) { diff --git a/views/templates/front/payment_execution_payme.tpl b/views/templates/front/payment_execution_payme.tpl index f93c937..057ddee 100644 --- a/views/templates/front/payment_execution_payme.tpl +++ b/views/templates/front/payment_execution_payme.tpl @@ -101,7 +101,7 @@ const run_waitMe = (bg='rgba(0,0,0, 0.7)') => { device: device, parameters3DS: parameters3DS }; - if (Culqi.token.metadata == undefined || Culqi.token.metadata.installments == undefined){ + if (Culqi.token.metadata != undefined && Culqi.token.metadata.installments != undefined){ payloadCharge.installments = Culqi.token.metadata.installments; } @@ -450,7 +450,7 @@ const run_waitMe = (bg='rgba(0,0,0, 0.7)') => { email: Culqi.token.email, device: device }; - if (Culqi.token.metadata == undefined || Culqi.token.metadata.installments == undefined){ + if (Culqi.token.metadata != undefined && Culqi.token.metadata.installments != undefined){ payloadCharge.installments = Culqi.token.metadata.installments; }