diff --git a/payco_whmcs/modules/gateways/callback/epayco.php b/payco_whmcs/modules/gateways/callback/epayco.php index 63170fb..aef864b 100644 --- a/payco_whmcs/modules/gateways/callback/epayco.php +++ b/payco_whmcs/modules/gateways/callback/epayco.php @@ -1,56 +1,55 @@ - isActiveGateway($gatewayModule) || !$gateway->load($gatewayModule)) { - WHMCS\Terminus::getInstance()->doDie("Module not Active"); -} -$GATEWAY = $gateway->getParams(); -$gatewayParams = getGatewayVariables('epayco'); + use Illuminate\Database\Capsule\Manager as Capsule; -if (!$gatewayParams['type']) { - die("Module Not Activated"); -} -if($_GET['ref_payco'] === 'undefined'){ - $returnUrl = $gatewayParams['systemurl']; -} -$obj = new EpaycoConfig("Epayco",$gatewayModule); + require_once(ROOTDIR . "/modules/gateways/epayco/epayco.php"); + $gatewayModule = "epayco"; + $gateway = new WHMCS\Module\Gateway(); + if (!$gateway->isActiveGateway($gatewayModule) || !$gateway->load($gatewayModule)) { + WHMCS\Terminus::getInstance()->doDie("Module not Active"); + } + $GATEWAY = $gateway->getParams(); + $gatewayParams = getGatewayVariables('epayco'); -if(!empty($_GET['ref_payco'])){ - $url = 'https://eks-checkout-service.epayco.io/validation/v1/reference/'.$_GET['ref_payco']; - $responseData = @file_get_contents($url); - if($responseData === false){ - echo "
ERROR: No se pudo obtener respuesta de la API
"; - logTransaction($gatewayParams['name'], $_GET, 'Ocurrio un error al intentar validar la referencia'); - header("Location: ".$gatewayParams['systemurl']); + if (!$gatewayParams['type']) { + die("Module Not Activated"); } - $jsonData = @json_decode($responseData, true); - - $validationData = $jsonData['data']; - - $obj->crearTablaCustomTransacciones(); - echo "
Procesando confirmación...
"; - $respuesta = $obj->epaycoConfirmation($GATEWAY, $validationData); - - $returnUrl = $gatewayParams['systemurl'].'modules/gateways/epayco/response.php'; - $fullRedirectUrl = $returnUrl.'?ref_payco='.$_GET['ref_payco']; - echo "
Redirigiendo...
"; - echo ""; - header("Location: ".$fullRedirectUrl); -}else { - if (!empty(trim($_REQUEST['x_ref_payco']))) { - $validationData = $_REQUEST; - $obj->crearTablaCustomTransacciones(); - $respuesta = $obj->epaycoConfirmation($GATEWAY,$validationData,true); - echo $respuesta; - header("HTTP/1.1 " . $respuesta); - exit("Callback completo: " . var_export(200,1)); + if ($_GET['ref_payco'] === 'undefined') { + $returnUrl = $gatewayParams['systemurl']; } -} \ No newline at end of file + $obj = new EpaycoConfig("Epayco", $gatewayModule); + + + if (!empty($_GET['ref_payco'])) { + $url = 'https://eks-checkout-service.epayco.io/validation/v1/reference/' . $_GET['ref_payco']; + $responseData = @file_get_contents($url); + if ($responseData === false) { + error_log("EPAYCO CALLBACK: file_get_contents FAILED", 0); + logTransaction($gatewayParams['name'], $_GET, 'Ocurrio un error al intentar validar la referencia'); + header("Location: " . $gatewayParams['systemurl']); + exit; + } + $jsonData = @json_decode($responseData, true); + $validationData = $jsonData['data']; + $obj->crearTablaCustomTransacciones(); + $respuesta = $obj->epaycoConfirmation($GATEWAY, $validationData); + + $returnUrl = $gatewayParams['systemurl'] . 'modules/gateways/epayco/response.php'; + $fullRedirectUrl = $returnUrl . '?ref_payco=' . $_GET['ref_payco']; + header("Location: " . $fullRedirectUrl); + exit; + }else { + if (!empty(trim($_REQUEST['x_ref_payco']))) { + $validationData = $_REQUEST; + $obj->crearTablaCustomTransacciones(); + $respuesta = $obj->epaycoConfirmation($GATEWAY, $validationData, true); + echo $respuesta; + header("HTTP/1.1 " . $respuesta); + exit("Callback completo: " . var_export(200, 1)); + } + } \ No newline at end of file