- <?php
- /*
- * @ https://EasyToYou.eu - IonCube v11 Decoder Online
- * @ PHP 7.2
- * @ Decoder version: 1.0.4
- * @ Release: 01/09/2021
- */
- function todopago_config()
- {
- $version = 1;
- $url = "https://bayresapp.com/versiones.php";
- $okd = curl_init();
- curl_setopt($okd, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($okd, CURLOPT_URL, $url);
- $destino = curl_exec($okd);
- $listado = json_decode($destino, true);
- $versiontp = $listado["todopago"];
- if ($version < $versiontp) {
- $msgversion = "<span style='color:red'>Módulo desactualizado - Última versión disponible: <b>v" . $versiontp . "</b></span>";
- } else {
- $msgversion = "<span style='color:green'>Módulo actualizado</span>";
- }
- $primeraparte = ["FriendlyName" => ["Type" => "System", "Value" => "TodoPago"], "bh_version" => ["FriendlyName" => "Versión:", "Description" => "TodoPago <b>v" . $version . "</b> by BayresApp - " . $msgversion]];
- $validado = ["bh_licencia" => ["FriendlyName" => "<span style='color:red'>Licencia del módulo</span>:", "Type" => "text", "Size" => "60", "Description" => "<br>Licencia</a>"]];
- $segundaparte = ["bh_local" => ["FriendlyName" => "<span style='color:red'>Verificador Local</span>:", "Description" => $BA_LOCAL], "bh_xxx" => ["FriendlyName" => "<span style='color:red'>MUY IMPORTANTE</span>:", "Description" => "<b>Para el correcto funcionamiento del módulo, es necesario que todos los campos en rojo sean completados.</b><br><br>\r\n\t\t\t\t\t\t\tLos datos correspondientes al Número de Comercio y Credenciales necesarios para utilizar este módulo, los encontrará ingresando en la web de TodoPago.\r\n\t\t\t\t\t\t\t<br>Botón [Integrar Mi Tienda]<br>Botón [Producción]."], "merchantId" => ["FriendlyName" => "<span style=\"color:red\">Número de Comercio:</span>", "Type" => "text", "Size" => "30", "Default" => "", "Description" => " Es un código numérico identificador del comercio. (Merchant ID)."], "authKey" => ["FriendlyName" => "<span style=\"color:red\">Credenciales:</span>", "Type" => "text", "Size" => "50", "Default" => "", "Description" => " Es un código alfanumérico correspondiente a la credencial para la utilización de la API de TodoPago (API Keys)"]];
- $configarray = array_merge($primeraparte, $validado, $segundaparte);
- return $configarray;
- }
- function todopago_link($params)
- {
- $gwAmount = $params["amount"];
- $bh_licencia = $params["bh_licencia"];
- $bh_local = $params["bh_local"];
- $systemUrl = $params["systemurl"];
- $url = $systemUrl . "modules/gateways/todopago/todopago_config.php";
- if ($params["clientdetails"]["country"] != "AR") {
- $htmlOutput = "<br><b>ERROR</b><br>Método de pago exclusivo para clientes residentes en Argentina";
- } else {
- $systemUrl = $GLOBALS["gatewayParams"]["systemurl"];
- $destino = $systemUrl . "clientarea.php?action=details";
- $errores = "<br><b>ERROR</b><br>Este método de pago requiere que complete los siguientes datos de su ficha de cliente:<br><ul>";
- if (empty($params["clientdetails"]["city"])) {
- $error = true;
- $errores .= "<li style='color: red;'>Ciudad de residencia</li>";
- }
- if (empty($params["clientdetails"]["phonenumber"])) {
- $error = true;
- $errores .= "<li style='color: red;'>Teléfono de contacto</li>";
- }
- if (empty($params["clientdetails"]["postcode"])) {
- $error = true;
- $errores .= "<li style='color: red;'>Código postal</li>";
- }
- if (empty($params["clientdetails"]["address1"])) {
- $error = true;
- $errores .= "<li style='color: red;'>Calle y número</li>";
- }
- $errores .= "</ul>\r\n\t\t<a href='" . $destino . "' title='Volver al sector clientes'class='btn btn-warning'><i class='fas fa-id-badge'></i> Actualizar datos</a>";
- $postfields["CSBTCITY"] = $params["clientdetails"]["city"];
- $postfields["CSBTCOUNTRY"] = $params["clientdetails"]["country"];
- $postfields["CSBTCUSTOMERID"] = $params["clientdetails"]["userid"];
- $postfields["CSBTIPADDRESS"] = $_SERVER["REMOTE_ADDR"];
- $postfields["CSBTEMAIL"] = $params["clientdetails"]["email"];
- $postfields["CSBTFIRSTNAME"] = $params["clientdetails"]["firstname"];
- $postfields["CSBTLASTNAME"] = $params["clientdetails"]["lastname"];
- $postfields["CSBTPHONENUMBER"] = $params["clientdetails"]["phonenumber"];
- $postfields["CSBTPOSTALCODE"] = $params["clientdetails"]["postcode"];
- $postfields["CSBTSTATE"] = "B";
- $postfields["CSBTSTREET1"] = $params["clientdetails"]["address1"];
- $postfields["CSSTCITY"] = $params["clientdetails"]["city"];
- $postfields["CSSTCOUNTRY"] = $params["clientdetails"]["country"];
- $postfields["CSSTEMAIL"] = $params["clientdetails"]["email"];
- $postfields["CSSTFIRSTNAME"] = $params["clientdetails"]["firstname"];
- $postfields["CSSTLASTNAME"] = $params["clientdetails"]["lastname"];
- $postfields["CSSTPHONENUMBER"] = $params["clientdetails"]["phonenumber"];
- $postfields["CSSTPOSTALCODE"] = $params["clientdetails"]["postcode"];
- $postfields["CSSTSTATE"] = "B";
- $postfields["CSSTSTREET1"] = $params["clientdetails"]["address1"];
- $postfields["CSPTCURRENCY"] = "ARS";
- $postfields["CSPTGRANDTOTALAMOUNT"] = number_format($gwAmount, 2, ".", "");
- $postfields["CSMDD8"] = "Y";
- $postfields["CSITPRODUCTSKU"] = $params["invoiceid"];
- $postfields["CSITPRODUCTDESCRIPTION"] = str_replace("#", "Nro.", $params["description"]);
- $postfields["CSITPRODUCTNAME"] = $postfields["CSITPRODUCTDESCRIPTION"];
- $postfields["CSITQUANTITY"] = "1";
- $postfields["CSITUNITPRICE"] = number_format($gwAmount, 2, ".", "");
- $postfields["CSITTOTALAMOUNT"] = number_format($postfields["CSITUNITPRICE"] * $postfields["CSITQUANTITY"], 2, ".", "");
- $licencia_valida = BAYRESAPP_Verificar_Licencia_TP($bh_licencia);
- if (!$licencia_valida[0]) {
- $htmlOutput = "TodoPago Licencia Inválida<br><pre>" . print_r($licencia_valida, true) . "</pre>";
- } else {
- $htmlOutput = "<form method=\"POST\" action=\"" . $url . "\">";
- $htmlOutput .= "<input type=\"image\" src=\"http://todopago.com.ar/sites/all/themes/pmcbotondepagopublico_theme/logo.png\" border=\"0\" alt=\"\">";
- foreach ($postfields as $k => $v) {
- $htmlOutput .= "<input type=\"hidden\" name=\"" . $k . "\" value=\"" . urlencode($v) . "\" />";
- }
- $htmlOutput .= "</br><input type=\"submit\" value=\"Pagar Ahora\" />";
- $htmlOutput .= "</form>";
- }
- return $htmlOutput;
- }
- }
- function BAYRESAPP_Verificar_Licencia_TP($bapp_licencia, $bapp_verificador = "")
- {
- if (!empty($bapp_verificador)) {
- $fecha_de_vencimiento = reconstruye_clave_tp($bapp_verificador);
- } else {
- $fecha_de_vencimiento = "1974-11-21";
- }
- $datetime1 = date_create($fecha_de_vencimiento);
- $datetime2 = new DateTime("now");
- if ($datetime2 < $datetime1) {
- $devuelve[] = true;
- } else {
- $version_del_modulo = "2";
- $id_del_modulo = "5";
- $urlbayres = "https://micuenta.bayresapp.com/modules/addons/bapplicencia/checklicense.php";
- $data = ["licencia" => $bapp_licencia, "version" => $version_del_modulo, "dominio" => $_SERVER["SERVER_NAME"], "dirpath" => dirname(__FILE__), "servicio" => $id_del_modulo];
- $cadena = http_build_query($data);
- $ch = curl_init($urlbayres);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLINFO_HEADER_OUT, true);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $cadena);
- $datos = curl_exec($ch);
- curl_close($ch);
- $datos_licencia = json_decode($datos, true);
- if ($datos_licencia["evaluacion"] != 1) {
- $devuelve[] = false;
- $devuelve["mensaje"] = $datos_licencia["error"];
- } else {
- $devuelve[] = true;
- }
- }
- unset($bapp_licencia);
- unset($bapp_verificador);
- unset($resultado);
- unset($fecha_de_vencimiento);
- unset($datos_licencia);
- return $devuelve;
- }
- function reconstruye_clave_tp($frase_de_seguridad)
- {
- $desglose_frase_seguridad = str_split($frase_de_seguridad);
- $fraseoriginal = $desglose_frase_seguridad[0] . $desglose_frase_seguridad[10] . $desglose_frase_seguridad[20] . $desglose_frase_seguridad[30] . $desglose_frase_seguridad[40] . $desglose_frase_seguridad[50] . $desglose_frase_seguridad[60] . $desglose_frase_seguridad[70];
- $fraseoriginal_cortada = str_split($fraseoriginal);
- foreach ($fraseoriginal_cortada as $letra) {
- switch ($letra) {
- case "M":
- $sopadeletras[] = "0";
- break;
- case "U":
- $sopadeletras[] = "1";
- break;
- case "R":
- $sopadeletras[] = "2";
- break;
- case "C":
- $sopadeletras[] = "3";
- break;
- case "I":
- $sopadeletras[] = "4";
- break;
- case "E":
- $sopadeletras[] = "5";
- break;
- case "L":
- $sopadeletras[] = "6";
- break;
- case "A":
- $sopadeletras[] = "7";
- break;
- case "G":
- $sopadeletras[] = "8";
- break;
- case "O":
- $sopadeletras[] = "9";
- break;
- }
- }
- $fecha_de_vencimiento = $sopadeletras[0] . $sopadeletras[1] . $sopadeletras[2] . $sopadeletras[3] . "-" . $sopadeletras[4] . $sopadeletras[5] . "-" . $sopadeletras[6] . $sopadeletras[7];
- $datetime1 = date_create($fecha_de_vencimiento);
- $datetime2 = new DateTime("now");
- if ($datetime2 < $datetime1) {
- $devuelve = true;
- } else {
- $devuelve = false;
- }
- return $fecha_de_vencimiento;
- }
- ?>