Jump to content

Módulo de Payu Latam - Integración de WHMCS con Payu Latam - Gateway Payu Latam for WHMCS


skenda

Recommended Posts

Hola a todos los usuarios de México, les comento que ya he podido realizar el módulo de Payu Latam para WHMCS. De esta forma podrás aceptar pagos con tarjetas de crédito o débito: Visa, Master Card y Merican Express, así como pagos en efectivo en tiendas OXXO y 7 Eleven.

 

Sólo tienes que crear un archivo llamado: payu.php

Súbe el archivo vía FTP en la siguiente ruta:

 

public_html/Tu instalación de WHMCS/modules/gateways/payu.php

 

 

 

 

 

<?php

###Desarrollado por Jesús Elizalde###
###### HOSTING SKENDA #######
# https://www.hostingskenda.com #
#######Módulo Gratuito########

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

function payu_activate() {
defineGatewayField("payu","text","merchantId",""," Id de comerciante","6","Ej.: <strong>500111</strong>");
defineGatewayField("payu","text","ApiKey","","Clav e","Ej.: <strong>1u77nqhq7ftd0hlvnjfs77ah1c</strong>");
defineGatewayField("payu","text","referenceCode"," ","Código de referencia","Ej.: <strong>00700</strong>");
defineGatewayField("payu","text","currency","" ,"Moneda","1","Pesos=MXN Dolares=USD");
defineGatewayField("payu","text","accountId","","I D Cuenta País","Ej.: <strong>501000</strong>");
defineGatewayField("payu","text","buyerEmail",""," Correo de vendedor","Ej.: <strong>info@hostingskenda.com</strong>");
}

function payu_link($params) {
# Gateway Specific Variables
$gatewaymerchantId = $params['merchantId'];
$gatewayApiKey = $params['ApiKey'];
$gatewayreferenceCode = $params['referenceCode'];
$gatewaycurrency = $params['currency'];
$gatewayaccountId = $params['accountId'];
$gatewaybuyerEmail = $params['buyerEmail'];
# 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.$gatewaymerchantId.$ gatewayreferenceCode.$amount.$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 type="submit" class="skenda" value="Pagar" />
</form><P>';

return $code;

}


?>

 

 

 

 

 

 

Una creado y subido el archivo ingresa a SETUP > Payments > Payment Gateway

 

Activa el módulo llamado PAYU, ingresa los datos solicitados y listo.

 

 

Cualquier duda o consulta estoy a sus órdenes.

 

 

Jesús Elizalde

 

México

Link to comment
Share on other sites

  • 3 weeks later...

Este es el modelo de codigo, para crear un modulo nuevo, quien sabe que debo modificar:

<?php

function payulatam_config() {
   $configarray = array(
    "FriendlyName" => array("Type" => "System", "Value"=>"Payulatam"),
    "username" => array("FriendlyName" => "Login ID", "Type" => "text", "Size" => "20", ),
    "transmethod" => array("FriendlyName" => "Transaction Method", "Type" => "dropdown", "Options" => "Option1,Value2,Method3", ),
    "instructions" => array("FriendlyName" => "Payment Instructions", "Type" => "textarea", "Rows" => "5", "Description" => "Do this then do that etc...", ),
    "testmode" => array("FriendlyName" => "Test Mode", "Type" => "yesno", "Description" => "Tick this to test", ),
   );
return $configarray;
}

function payulatam_link($params) {

# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

# Invoice Variables
$invoiceid = $params['invoiceid'];
$description = $params["description"];
   	$amount = $params['amount']; # Format: ##.##
   	$currency = $params['currency']; # Currency Code

# 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'];

# Enter your code submit to the gateway...

$code = '<form method="https://gateway.payulatam.com/ppp-web-gateway">
<input type="hidden" name="username" value="'.$gatewayusername.'" />
<input type="hidden" name="testmode" value="'.$gatewaytestmode.'" />
<input type="hidden" name="description" value="'.$description.'" />
<input type="hidden" name="invoiceid" value="'.$invoiceid.'" />
<input type="hidden" name="amount" value="'.$amount.'" />
<input type="submit" value="Pay Now" />
</form>';

return $code;
}

function payulatam_capture($params) {

   	# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

   	# Invoice Variables
$invoiceid = $params['invoiceid'];
$amount = $params['amount']; # Format: ##.##
   	$currency = $params['currency']; # Currency Code

   	# 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'];

# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];

# Perform Transaction Here & Generate $results Array, eg:
$results = array();
$results["status"] = "success";
   	$results["transid"] = "12345";

# Return Results
if ($results["status"]=="success") {
	return array("status"=>"success","transid"=>$results["transid"],"rawdata"=>$results);
} elseif ($gatewayresult=="declined") {
       return array("status"=>"declined","rawdata"=>$results);
   	} else {
	return array("status"=>"error","rawdata"=>$results);
}

}

function payulatam_refund($params) {

   # Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

   # Invoice Variables
$transid = $params['transid']; # Transaction ID of Original Payment
$amount = $params['amount']; # Format: ##.##
   $currency = $params['currency']; # Currency Code

       # 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'];

# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];

# Perform Refund Here & Generate $results Array, eg:
$results = array();
$results["status"] = "success";
   	$results["transid"] = "12345";

# Return Results
if ($results["status"]=="success") {
	return array("status"=>"success","transid"=>$results["transid"],"rawdata"=>$results);
} elseif ($gatewayresult=="declined") {
       return array("status"=>"declined","rawdata"=>$results);
   	} else {
	return array("status"=>"error","rawdata"=>$results);
}
}

?>

Link to comment
Share on other sites

Buenas tardes

Reciba un cordial saludo

 

Respecto al módulo, favor de verificar que en su cuenta de Payu no tengan una casilla activa llamada "Test Mode". Ya que el módulo está configurado en el servidor de producción.

 

Voy a investigar si hay alguna diferencia de integración en colombia.

 

Ante cualquier pueden escribirme a: info@hostingskenda.com

Link to comment
Share on other sites

  • 3 weeks later...

Hola edinsof,

Ensaye y si me dio, Mil gracias. :idea:

 

Depronto sabes que puede estar causando este error "La orden con referencia [#] no pudo ser procesada, la firma no es valida." en donde esta el #, va el numero de factura o el referenceCode.

Edited by SoporteSA
Link to comment
Share on other sites

  • 5 months later...
Hola edinsof,

Ensaye y si me dio, Mil gracias. :idea:

 

Depronto sabes que puede estar causando este error "La orden con referencia [#] no pudo ser procesada, la firma no es valida." en donde esta el #, va el numero de factura o el referenceCode.

 

 

Payu realizo uan serie de actualizaciones, si desea puede adquirir el nuevo modulo de PayuLatam versión 3.3.0 con todas las actualizaciones en Gateways Payulatam for WHMCS

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
  • 4 months later...

Buenas tardes

 

Adjunto una corrección del módulo de pagos de Payu Latam para WHMCS

 

<?php

###Desarrollado por Jesús Elizalde###
######       SKENDA       #######
#    https://www.skenda.hosting    #
#####   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 sesión");
defineGatewayField("payu","text","merchantId","","Id Comercio","6","Ej. <strong>500238</strong> Se encuentra en la sección de configuración");
defineGatewayField("payu","text","ApiKey","","Api Key","30","Ej. <strong>6u39nvhq8fsd0hrvfjf66eh8c</strong> Se encuentra en la sección de configuración.");
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>usuario@skenda.host</strong> Email que utilizas en tu cuenta de Payu");
}

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'];
  # 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.$gatewaymerchantId.$gatewayreferenceCode.$amount.$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 type="submit" class="skenda" value="Pagar" />
</form><P>';

return $code;

}


?>

 

Cualquier duda estoy a sus órdenes en soporte@skenda.host

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated