Módulo gratuito para integrar Payu en WHMCS

 

Pasos para crear el módulo:

1  - Copiar el código

2 - Crear un archivo payu.php y subirlo con ftp a "public_html/Tu directorio de WHMCS/modules/gateways/payu.php"

3 - Configurar el módulo desde WHMCS

---------------------------------------------------

<?php 

#####   Módulo Gratuito  ###### 

$GATEWAYMODULE["payuname"]="payu"; 
$GATEWAYMODULE["payuvisiblename"]="Payu"; 
$GATEWAYMODULE["payutype"]="Invoices"; 

function payu_activate() { 
defineGatewayField("payu","text","accountId","","Id Cuenta","6","Ej. <strong>501000</strong> Se encuentra al iniciar sesion"); 
defineGatewayField("payu","text","merchantId","","Id Comercio","6","Ej. <strong>500238</strong> Se encuentra en la sección de configuracion"); 
defineGatewayField("payu","text","ApiKey","","Api Key","30","Ej. <strong>6u39nvhq8fsd0hrvfjf66eh8c</strong> Se encuentra en la sección de configuracion."); 
defineGatewayField("payu","text","currency","" ,"Moneda","3","Peso Mexicano: <strong>MXN</strong>, Dolares: <strong>USD</strong>, Peso Colombiano: <strong>COP</strong>, Peso Argentino: <strong>ARS</strong>, Real Brasileño: <strong>BRL</strong>, Peso Chileno: <strong>CLP</strong>, Nuevo Sol Peruano: <strong>PEN</strong>"); 
defineGatewayField("payu","text","buyerEmail","","Correo de vendedor","30","Ej. <strong>Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo.Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo.;/strong> Email que utilizas en tu cuenta de Payu"); 
defineGatewayField("payu","text","string","","separador","30","Ej. <strong>~</strong> Ingrese este caracter");

function payu_link($params) { 
   # Gateway Specific Variables 
   $gatewaymerchantId = $params['merchantId']; 
   $gatewayApiKey = $params['ApiKey']; 
   $gatewayreferenceCode = $params['invoiceid']; 
   $gatewaycurrency = $params['currency']; 
   $gatewayaccountId = $params['accountId']; 
   $gatewaybuyerEmail = $params['buyerEmail'];

   $gatewaystring = $params['string']; 

   # Invoice Variables 
   $invoiceid = $params['invoiceid']; 
   $description = $params["description"]; 
   $amount = $params['amount']; 
   $currency = $params['currency']; 
   $duedate = $params['duedate']; 
   # Client Variables 
   $firstname = $params['clientdetails']['firstname']; 
   $lastname = $params['clientdetails']['lastname']; 
   $email = $params['clientdetails']['email']; 
   $address1 = $params['clientdetails']['address1']; 
   $address2 = $params['clientdetails']['address2']; 
   $city = $params['clientdetails']['city']; 
   $state = $params['clientdetails']['state']; 
   $postcode = $params['clientdetails']['postcode']; 
   $country = $params['clientdetails']['country']; 
   $phone = $params['clientdetails']['phonenumber']; 
   # System Variables 
   $companyname = $params['companyname']; 
   $systemurl = $params['systemurl']; 
   $currency = $params['currency']; 
   # End of Variables 

   //print_r($params); 
    
   // Redondeo de centavos. 0.4 lo redondea hacia abajo, 0.5 lo redondea hacia arriba. 
  //$amount = round($amount); 
    $signature = md5($gatewayApiKey.$gatewaystring.$gatewaymerchantId.$gatewaystring.$gatewayreferenceCode.$gatewaystring.$amount.$gatewaystring.$gatewaycurrency);

$code .= '<P><form action="https://gateway.payulatam.com/ppp-web-gateway" method="post">  
<input type="hidden" value="'.$gatewaymerchantId.'" name="merchantId"> 
<input type="hidden" value="'.$gatewayapikey.'" name="ApiKey"> 
<input type="hidden" value="'.$gatewayreferenceCode.'" name="referenceCode"> 
<input type="hidden" value="'.$gatewayaccountId.'" name="accountId"> 
<input type="hidden" value="'.$description.'" name="description"> 
<input type="hidden" value="'.$amount.'" name="amount"> 
<input type="hidden" value="0" name="tax"> 
<input type="hidden" value="0" name="taxReturnBase"> 
<input type="hidden" value="'.$gatewaycurrency.'" name="currency"> 
<input type="hidden" value="'.$signature.'" name="signature"> 
<input type="hidden" value="'.$gatewaybuyerEmail.'" name="buyerEmail"> 
<input name="Submit" type="submit" value="Pagar" />
</form><P>'; 

return $code; 


?>