Skip to content

Commit

Permalink
Merge pull request #60 from culqi/release-3.0.1
Browse files Browse the repository at this point in the history
Release 3.0.1
  • Loading branch information
JoseHCalderon authored Nov 18, 2022
2 parents a076296 + f447c1d commit 6c01c5e
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 6 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added controllers/.DS_Store
Binary file not shown.
21 changes: 19 additions & 2 deletions controllers/front/webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,34 @@ public function displayAjax()
{

Logger::addLog('Inicio weebhook');

$postBody = file_get_contents("php://input");
$headers = getallheaders();
$headers = $headers['Authorization'];
if(!isset($headers)){
exit("Error: Cabecera Authorization no presente");
}
$authorization = substr($headers,6);
$credenciales = base64_decode($authorization);
$credenciales = explode( ':', $credenciales );
$username = $credenciales[0];
$password = $credenciales[1];
if(!isset($username) or !isset($password)){
exit("Error: No Autorizado");
}
$postBody = json_decode($postBody, true);
$data = json_decode($postBody["data"], true);
Logger::addLog('$data ' . serialize($data));

$currencyCode = trim($data['currency_code']);
$state = trim($data['state']);
$amount = trim($data['amount']);
$order_number = trim($data['order_number']);
$id = trim($data['id']);
$settings = $this->module->getConfigFieldsValues();
$username_bd = $settings['CULQI_USERNAME'];
$password_bd = $settings['CULQI_PASSWORD'];
if( $username != $username_bd || $password != $password_bd ){
exit("Error: Crendenciales Incorrectas");
}
if (empty($amount)) {
echo json_encode(['success'=>'false', 'msj'=>'No envió el amount']);
exit();
Expand Down
25 changes: 24 additions & 1 deletion culqi.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public function install()
Configuration::updateValue('CULQI_METHODS_QUOTEBCP', '') &&
Configuration::updateValue('CULQI_TIMEXP', '') &&
Configuration::updateValue('CULQI_NOTPAY', '') &&
Configuration::updateValue('CULQI_USERNAME', '') &&
Configuration::updateValue('CULQI_PASSWORD', '') &&
Configuration::updateValue('CULQI_URL_LOGO', '') &&
Configuration::updateValue('CULQI_COLOR_PALETTE', '')
);
Expand Down Expand Up @@ -302,6 +304,8 @@ public function uninstall()
|| !Configuration::deleteByName('CULQI_METHODS_QUOTEBCP')
|| !Configuration::deleteByName('CULQI_TIMEXP')
|| !Configuration::deleteByName('CULQI_NOTPAY')
|| !Configuration::deleteByName('CULQI_USERNAME')
|| !Configuration::deleteByName('CULQI_PASSWORD')
|| !Configuration::deleteByName('CULQI_URL_LOGO')
|| !Configuration::deleteByName('CULQI_COLOR_PALETTE')
|| !$this->uninstallStates())
Expand Down Expand Up @@ -465,7 +469,20 @@ public function renderForm()
//var_dump(__FILE__); exit(1);
return $this->display(__FILE__, '/views/templates/hook/setting.tpl');
}

public function generate_username() {
$username_bd = Tools::getValue('CULQI_USERNAME', Configuration::get('CULQI_USERNAME'));
if($username_bd == '' || $username_bd == null){
return bin2hex(random_bytes(5));
}
return $username_bd;
}
public function generate_password() {
$password_bd = Tools::getValue('CULQI_PASSWORD', Configuration::get('CULQI_PASSWORD'));
if($password_bd == '' || $password_bd == null){
return bin2hex(random_bytes(10));
}
return $password_bd;
}
public function getConfigFieldsValues()
{
$checked_integ = 'checked="true"';
Expand All @@ -482,6 +499,8 @@ public function getConfigFieldsValues()
$urlapi_merchantsingle = URLAPI_MERCHANTSINGLE_PROD;
$urlapi_webhook = URLAPI_WEBHOOK_PROD;
}
$username = $this->generate_username();
$password = $this->generate_password();
$post = 0;
if(isset($_POST['btnSubmit']) and $_POST['btnSubmit']==1){
$post = 1;
Expand All @@ -500,6 +519,8 @@ public function getConfigFieldsValues()
'CULQI_METHODS_QUOTEBCP' => Tools::getValue('CULQI_METHODS_QUOTEBCP', Configuration::get('CULQI_METHODS_QUOTEBCP')),
'CULQI_TIMEXP' => Tools::getValue('CULQI_TIMEXP', Configuration::get('CULQI_TIMEXP')),
'CULQI_NOTPAY' => Tools::getValue('CULQI_NOTPAY', Configuration::get('CULQI_NOTPAY')),
'CULQI_USERNAME' =>$username,
'CULQI_PASSWORD' =>$password,
'CULQI_URL_LOGO' => Tools::getValue('CULQI_URL_LOGO', Configuration::get('CULQI_URL_LOGO')),
'CULQI_COLOR_PALETTE' => Tools::getValue('CULQI_COLOR_PALETTE', Configuration::get('CULQI_COLOR_PALETTE')),
'CULQI_COLOR_PALETTEID' => str_replace('#', '', Tools::getValue('CULQI_COLOR_PALETTE', Configuration::get('CULQI_COLOR_PALETTE'))),
Expand Down Expand Up @@ -540,6 +561,8 @@ private function _postProcess()
Configuration::updateValue('CULQI_METHODS_QUOTEBCP', Tools::getValue('CULQI_METHODS_QUOTEBCP'));
Configuration::updateValue('CULQI_TIMEXP', Tools::getValue('CULQI_TIMEXP'));
Configuration::updateValue('CULQI_NOTPAY', Tools::getValue('CULQI_NOTPAY'));
Configuration::updateValue('CULQI_USERNAME', Tools::getValue('CULQI_USERNAME'));
Configuration::updateValue('CULQI_PASSWORD', Tools::getValue('CULQI_PASSWORD'));
Configuration::updateValue('CULQI_URL_LOGO', Tools::getValue('CULQI_URL_LOGO'));
Configuration::updateValue('CULQI_COLOR_PALETTE', Tools::getValue('CULQI_COLOR_PALETTE'));
}
Expand Down
Binary file added views/.DS_Store
Binary file not shown.
Binary file added views/templates/.DS_Store
Binary file not shown.
7 changes: 6 additions & 1 deletion views/templates/front/payment_execution_payme.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@

// GENERAR DEVICE ID (INVOCAR APENAS SE DE AL BOTON PAGAR Y ABRA EL CULQI CHECKOUT)
Culqi3DS.publicKey = "{/literal}{$llave_publica|escape:'htmlall':'UTF-8'}{literal}";
var device = await Culqi3DS.generateDevice();
//var device = await Culqi3DS.generateDevice();
async function generateDevice(){
const device = await Culqi3DS.generateDevice();
return device;
}
var device = generateDevice();
var orderid = '';

$(document).ready(function () {
Expand Down
20 changes: 18 additions & 2 deletions views/templates/hook/setting.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,20 @@
<input type="text" name="CULQI_NOTPAY" id="CULQI_NOTPAY"
value="{$fields_value.CULQI_URL_WEBHOOK_PS|escape:'htmlall':'UTF-8'}" readonly="true"
class="">
<span class="form-text text-muted"> Si no iniciaste sesión con tu cuenta de Culqi Panel, tienes que configurar esta URL.</span>
<span class="form-text text-muted"> Si no iniciaste sesión con tu cuenta de Culqi Panel, tienes que configurar esta URL colocando estas credenciales:</span><br>
<b>Usuario:</b> {$fields_value.CULQI_USERNAME|escape:'htmlall':'UTF-8'} <b>Password:</b> {$fields_value.CULQI_PASSWORD|escape:'htmlall':'UTF-8'}<br>

</div>
</div>

<div class="form-group" style="display: none;">
<div class="col-lg-8">
<input type="hidden" name="CULQI_USERNAME" id="CULQI_USERNAME"
value="{$fields_value.CULQI_USERNAME|escape:'htmlall':'UTF-8'}"
class="">
<input type="hidden" name="CULQI_PASSWORD" id="CULQI_PASSWORD"
value="{$fields_value.CULQI_PASSWORD|escape:'htmlall':'UTF-8'}"
class="">
</div>
</div>

Expand Down Expand Up @@ -2771,7 +2784,10 @@
"merchant": jQuery('#CULQI_LLAVE_PUBLICA').val(),
"eventId": "order.status.changed",
"url": jQuery('#CULQI_NOTPAY').val(),
"version": 2
"version": 2,
"loginActive": true,
"username": jQuery('#CULQI_USERNAME').val(),
"password": jQuery('#CULQI_PASSWORD').val()
}),
};
jQuery.ajax(settings).done(function (response) {
Expand Down

0 comments on commit 6c01c5e

Please sign in to comment.