1. <?php
  2. /*
  3. * @ https://EasyToYou.eu - IonCube v11 Decoder Online
  4. * @ PHP 7.2
  5. * @ Decoder version: 1.0.4
  6. * @ Release: 01/09/2021
  7. */
  8. function todopago_config()
  9. {
  10. $version = 1;
  11. $url = "https://bayresapp.com/versiones.php";
  12. $okd = curl_init();
  13. curl_setopt($okd, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($okd, CURLOPT_URL, $url);
  15. $destino = curl_exec($okd);
  16. $listado = json_decode($destino, true);
  17. $versiontp = $listado["todopago"];
  18. if ($version < $versiontp) {
  19. $msgversion = "<span style='color:red'>Módulo desactualizado - Última versión disponible: <b>v" . $versiontp . "</b></span>";
  20. } else {
  21. $msgversion = "<span style='color:green'>Módulo actualizado</span>";
  22. }
  23. $primeraparte = ["FriendlyName" => ["Type" => "System", "Value" => "TodoPago"], "bh_version" => ["FriendlyName" => "Versión:", "Description" => "TodoPago <b>v" . $version . "</b> by BayresApp - " . $msgversion]];
  24. $validado = ["bh_licencia" => ["FriendlyName" => "<span style='color:red'>Licencia del módulo</span>:", "Type" => "text", "Size" => "60", "Description" => "<br>Licencia</a>"]];
  25. $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" => "&nbsp;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" => "&nbsp; Es un código alfanumérico correspondiente a la credencial para la utilización de la API de TodoPago (API Keys)"]];
  26. $configarray = array_merge($primeraparte, $validado, $segundaparte);
  27. return $configarray;
  28. }
  29. function todopago_link($params)
  30. {
  31. $gwAmount = $params["amount"];
  32. $bh_licencia = $params["bh_licencia"];
  33. $bh_local = $params["bh_local"];
  34. $systemUrl = $params["systemurl"];
  35. $url = $systemUrl . "modules/gateways/todopago/todopago_config.php";
  36. if ($params["clientdetails"]["country"] != "AR") {
  37. $htmlOutput = "<br><b>ERROR</b><br>Método de pago exclusivo para clientes residentes en Argentina";
  38. } else {
  39. $systemUrl = $GLOBALS["gatewayParams"]["systemurl"];
  40. $destino = $systemUrl . "clientarea.php?action=details";
  41. $errores = "<br><b>ERROR</b><br>Este método de pago requiere que complete los siguientes datos de su ficha de cliente:<br><ul>";
  42. if (empty($params["clientdetails"]["city"])) {
  43. $error = true;
  44. $errores .= "<li style='color: red;'>Ciudad de residencia</li>";
  45. }
  46. if (empty($params["clientdetails"]["phonenumber"])) {
  47. $error = true;
  48. $errores .= "<li style='color: red;'>Teléfono de contacto</li>";
  49. }
  50. if (empty($params["clientdetails"]["postcode"])) {
  51. $error = true;
  52. $errores .= "<li style='color: red;'>Código postal</li>";
  53. }
  54. if (empty($params["clientdetails"]["address1"])) {
  55. $error = true;
  56. $errores .= "<li style='color: red;'>Calle y número</li>";
  57. }
  58. $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>";
  59. $postfields["CSBTCITY"] = $params["clientdetails"]["city"];
  60. $postfields["CSBTCOUNTRY"] = $params["clientdetails"]["country"];
  61. $postfields["CSBTCUSTOMERID"] = $params["clientdetails"]["userid"];
  62. $postfields["CSBTIPADDRESS"] = $_SERVER["REMOTE_ADDR"];
  63. $postfields["CSBTEMAIL"] = $params["clientdetails"]["email"];
  64. $postfields["CSBTFIRSTNAME"] = $params["clientdetails"]["firstname"];
  65. $postfields["CSBTLASTNAME"] = $params["clientdetails"]["lastname"];
  66. $postfields["CSBTPHONENUMBER"] = $params["clientdetails"]["phonenumber"];
  67. $postfields["CSBTPOSTALCODE"] = $params["clientdetails"]["postcode"];
  68. $postfields["CSBTSTATE"] = "B";
  69. $postfields["CSBTSTREET1"] = $params["clientdetails"]["address1"];
  70. $postfields["CSSTCITY"] = $params["clientdetails"]["city"];
  71. $postfields["CSSTCOUNTRY"] = $params["clientdetails"]["country"];
  72. $postfields["CSSTEMAIL"] = $params["clientdetails"]["email"];
  73. $postfields["CSSTFIRSTNAME"] = $params["clientdetails"]["firstname"];
  74. $postfields["CSSTLASTNAME"] = $params["clientdetails"]["lastname"];
  75. $postfields["CSSTPHONENUMBER"] = $params["clientdetails"]["phonenumber"];
  76. $postfields["CSSTPOSTALCODE"] = $params["clientdetails"]["postcode"];
  77. $postfields["CSSTSTATE"] = "B";
  78. $postfields["CSSTSTREET1"] = $params["clientdetails"]["address1"];
  79. $postfields["CSPTCURRENCY"] = "ARS";
  80. $postfields["CSPTGRANDTOTALAMOUNT"] = number_format($gwAmount, 2, ".", "");
  81. $postfields["CSMDD8"] = "Y";
  82. $postfields["CSITPRODUCTSKU"] = $params["invoiceid"];
  83. $postfields["CSITPRODUCTDESCRIPTION"] = str_replace("#", "Nro.", $params["description"]);
  84. $postfields["CSITPRODUCTNAME"] = $postfields["CSITPRODUCTDESCRIPTION"];
  85. $postfields["CSITQUANTITY"] = "1";
  86. $postfields["CSITUNITPRICE"] = number_format($gwAmount, 2, ".", "");
  87. $postfields["CSITTOTALAMOUNT"] = number_format($postfields["CSITUNITPRICE"] * $postfields["CSITQUANTITY"], 2, ".", "");
  88. $licencia_valida = BAYRESAPP_Verificar_Licencia_TP($bh_licencia);
  89. if (!$licencia_valida[0]) {
  90. $htmlOutput = "TodoPago Licencia Inválida<br><pre>" . print_r($licencia_valida, true) . "</pre>";
  91. } else {
  92. $htmlOutput = "<form method=\"POST\" action=\"" . $url . "\">";
  93. $htmlOutput .= "<input type=\"image\" src=\"http://todopago.com.ar/sites/all/themes/pmcbotondepagopublico_theme/logo.png\" border=\"0\" alt=\"\">";
  94. foreach ($postfields as $k => $v) {
  95. $htmlOutput .= "<input type=\"hidden\" name=\"" . $k . "\" value=\"" . urlencode($v) . "\" />";
  96. }
  97. $htmlOutput .= "</br><input type=\"submit\" value=\"Pagar Ahora\" />";
  98. $htmlOutput .= "</form>";
  99. }
  100. return $htmlOutput;
  101. }
  102. }
  103. function BAYRESAPP_Verificar_Licencia_TP($bapp_licencia, $bapp_verificador = "")
  104. {
  105. if (!empty($bapp_verificador)) {
  106. $fecha_de_vencimiento = reconstruye_clave_tp($bapp_verificador);
  107. } else {
  108. $fecha_de_vencimiento = "1974-11-21";
  109. }
  110. $datetime1 = date_create($fecha_de_vencimiento);
  111. $datetime2 = new DateTime("now");
  112. if ($datetime2 < $datetime1) {
  113. $devuelve[] = true;
  114. } else {
  115. $version_del_modulo = "2";
  116. $id_del_modulo = "5";
  117. $urlbayres = "https://micuenta.bayresapp.com/modules/addons/bapplicencia/checklicense.php";
  118. $data = ["licencia" => $bapp_licencia, "version" => $version_del_modulo, "dominio" => $_SERVER["SERVER_NAME"], "dirpath" => dirname(__FILE__), "servicio" => $id_del_modulo];
  119. $cadena = http_build_query($data);
  120. $ch = curl_init($urlbayres);
  121. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0");
  122. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  123. curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  124. curl_setopt($ch, CURLOPT_POST, true);
  125. curl_setopt($ch, CURLOPT_POSTFIELDS, $cadena);
  126. $datos = curl_exec($ch);
  127. curl_close($ch);
  128. $datos_licencia = json_decode($datos, true);
  129. if ($datos_licencia["evaluacion"] != 1) {
  130. $devuelve[] = false;
  131. $devuelve["mensaje"] = $datos_licencia["error"];
  132. } else {
  133. $devuelve[] = true;
  134. }
  135. }
  136. unset($bapp_licencia);
  137. unset($bapp_verificador);
  138. unset($resultado);
  139. unset($fecha_de_vencimiento);
  140. unset($datos_licencia);
  141. return $devuelve;
  142. }
  143. function reconstruye_clave_tp($frase_de_seguridad)
  144. {
  145. $desglose_frase_seguridad = str_split($frase_de_seguridad);
  146. $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];
  147. $fraseoriginal_cortada = str_split($fraseoriginal);
  148. foreach ($fraseoriginal_cortada as $letra) {
  149. switch ($letra) {
  150. case "M":
  151. $sopadeletras[] = "0";
  152. break;
  153. case "U":
  154. $sopadeletras[] = "1";
  155. break;
  156. case "R":
  157. $sopadeletras[] = "2";
  158. break;
  159. case "C":
  160. $sopadeletras[] = "3";
  161. break;
  162. case "I":
  163. $sopadeletras[] = "4";
  164. break;
  165. case "E":
  166. $sopadeletras[] = "5";
  167. break;
  168. case "L":
  169. $sopadeletras[] = "6";
  170. break;
  171. case "A":
  172. $sopadeletras[] = "7";
  173. break;
  174. case "G":
  175. $sopadeletras[] = "8";
  176. break;
  177. case "O":
  178. $sopadeletras[] = "9";
  179. break;
  180. }
  181. }
  182. $fecha_de_vencimiento = $sopadeletras[0] . $sopadeletras[1] . $sopadeletras[2] . $sopadeletras[3] . "-" . $sopadeletras[4] . $sopadeletras[5] . "-" . $sopadeletras[6] . $sopadeletras[7];
  183. $datetime1 = date_create($fecha_de_vencimiento);
  184. $datetime2 = new DateTime("now");
  185. if ($datetime2 < $datetime1) {
  186. $devuelve = true;
  187. } else {
  188. $devuelve = false;
  189. }
  190. return $fecha_de_vencimiento;
  191. }
  192. ?>