Uncaught exception 'PayUException' with message 'The payment order with id [7757036] is already registered with reference code [payment_test_00000001]

1,381 views
Skip to first unread message

Jaime Irazabal

unread,
Apr 15, 2016, 6:25:40 PM4/15/16
to Desarrolladores PayU Latam
Hola tengo el siguiente error:
Fatal error:  Uncaught exception 'PayUException' with message 'The payment order with id [7757036] is already registered with reference code [payment_test_00000001].' in /var/www/html/librerias/php/payu/payu-php-sdk-4.5.6/lib/PayU/util/PayUApiServiceUtil.php:67
Stack trace:
#0 /var/www/html/librerias/php/payu/payu-php-sdk-4.5.6/lib/PayU/PayUPayments.php(200): PayUApiServiceUtil::sendRequest(Object(stdClass), Object(PayUHttpRequestInfo))
#1 /var/www/html/librerias/php/payu/payu-php-sdk-4.5.6/lib/PayU/PayUPayments.php(88): PayUPayments::doPayment(Array, 'AUTHORIZATION_A...', NULL)
#2 /var/www/html/librerias/php/payu/index.php(133): PayUPayments::doAuthorizationAndCapture(Array)
#3 {main}
  thrown in /var/www/html/librerias/php/payu/payu-php-sdk-4.5.6/lib/PayU/util/PayUApiServiceUtil.php on line 67

con el siguiente codigo:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Payu</title>
<style type="text/css">
body{
background: grey;
font-family: "arial", sans-serif;
}
.container{
width:600px;
margin:auto;
background: white;
padding:15px;
}
.containter h2{
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<h2>Compra de producto</h2>
<form action="">
<label for="">Producto</label><br>
<input type="text" name="producto"><br>
<label for="">Monto</label><br>
<input type="text" name="monto"><br>
<input type="submit" value="Comprar">
</form>
</div>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include_once ("payu-php-sdk-4.5.6/lib/PayU.php");
echo "<pre>";
// Payments URL
Environment::setPaymentsCustomUrl("https://stg.api.payulatam.com/payments-api/4.0/service.cgi");
// Queries URL
Environment::setReportsCustomUrl("https://stg.api.payulatam.com/reports-api/4.0/service.cgi");
// Subscriptions for recurring payments URL
Environment::setSubscriptionsCustomUrl("https://stg.api.payulatam.com/payments-api/rest/v4.3/");

PayU::$isTest = true;
PayU::$apiKey = "6u39nqhq8ftd0hlvnjfs66eh8c"; //Enter your own apiKey here.
PayU::$apiLogin = "11959c415b33d0c"; //Enter your own apiLogin here.
PayU::$merchantId = "500238"; //Enter your commerce Id here.
PayU::$language = SupportedLanguages::ES; //Select the language.

$reference = "payment_test_00000001";
$value = "10000";


//para realizar un pago con tarjeta de crédito---------------------------------
$parameters = array(
//Ingrese aquí el identificador de la cuenta.
PayUParameters::ACCOUNT_ID => "500538",
//Ingrese aquí el código de referencia.
PayUParameters::REFERENCE_CODE => $reference,
//Ingrese aquí la descripción.
PayUParameters::DESCRIPTION => "payment test",

// -- Valores --
//Ingrese aquí el valor.
PayUParameters::VALUE => $value,
//Ingrese aquí la moneda.
PayUParameters::CURRENCY => "COP",

// -- Comprador
//Ingrese aquí el nombre del comprador.
PayUParameters::BUYER_NAME => "First name and second buyer name",
//Ingrese aquí el email del comprador.
PayUParameters::BUYER_EMAIL => "buyer...@test.com",
//Ingrese aquí el teléfono de contacto del comprador.
PayUParameters::BUYER_CONTACT_PHONE => "7563126",
//Ingrese aquí el documento de contacto del comprador.
PayUParameters::BUYER_DNI => "5415668464654",
//Ingrese aquí la dirección del comprador.
PayUParameters::BUYER_STREET => "calle 100",
PayUParameters::BUYER_STREET_2 => "5555487",
PayUParameters::BUYER_CITY => "Medellin",
PayUParameters::BUYER_STATE => "Antioquia",
PayUParameters::BUYER_COUNTRY => "CO",
PayUParameters::BUYER_POSTAL_CODE => "000000",
PayUParameters::BUYER_PHONE => "7563126",

// -- pagador --
//Ingrese aquí el nombre del pagador.
PayUParameters::PAYER_NAME => "APPROVED",
//Ingrese aquí el email del pagador.
PayUParameters::PAYER_EMAIL => "payer...@test.com",
//Ingrese aquí el teléfono de contacto del pagador.
PayUParameters::PAYER_CONTACT_PHONE => "7563126",
//Ingrese aquí el documento de contacto del pagador.
PayUParameters::PAYER_DNI => "5415668464654",
//Ingrese aquí la dirección del pagador.
PayUParameters::PAYER_STREET => "calle 93",
PayUParameters::PAYER_STREET_2 => "125544",
PayUParameters::PAYER_CITY => "Bogota",
PayUParameters::PAYER_STATE => "Bogota",
PayUParameters::PAYER_COUNTRY => "CO",
PayUParameters::PAYER_POSTAL_CODE => "000000",
PayUParameters::PAYER_PHONE => "7563126",

// -- Datos de la tarjeta de crédito --
//Ingrese aquí el número de la tarjeta de crédito
PayUParameters::CREDIT_CARD_NUMBER => "4097440000000004",
//Ingrese aquí la fecha de vencimiento de la tarjeta de crédito
PayUParameters::CREDIT_CARD_EXPIRATION_DATE => "2014/12",
//Ingrese aquí el código de seguridad de la tarjeta de crédito
PayUParameters::CREDIT_CARD_SECURITY_CODE=> "321",
//Ingrese aquí el nombre de la tarjeta de crédito
//VISA||MASTERCARD||AMEX||DINERS
PayUParameters::PAYMENT_METHOD => "VISA",

//Ingrese aquí el número de cuotas.
PayUParameters::INSTALLMENTS_NUMBER => "1",
//Ingrese aquí el nombre del pais.
PayUParameters::COUNTRY => PayUCountries::CO,

//Session id del device.
PayUParameters::DEVICE_SESSION_ID => "vghs6tvkcle931686k1900o6e1",
//IP del pagadador
PayUParameters::IP_ADDRESS => "127.0.0.1",
//Cookie de la sesión actual.
PayUParameters::PAYER_COOKIE=>"pt1t38347bs6jc9ruv2ecpv7o2",
//Cookie de la sesión actual.
PayUParameters::USER_AGENT=>"Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"
);

//solicitud de autorización y captura
$response = PayUPayments::doAuthorizationAndCapture($parameters);

// -- podrás obtener las propiedades de la respuesta --
if($response){
$response->transactionResponse->orderId;
$response->transactionResponse->transactionId;
$response->transactionResponse->state;
if($response->transactionResponse->state=="PENDING"){
$response->transactionResponse->pendingReason;
}
$response->transactionResponse->paymentNetworkResponseCode;
$response->transactionResponse->paymentNetworkResponseErrorMessage;
$response->transactionResponse->trazabilityCode;
$response->transactionResponse->responseCode;
$response->transactionResponse->responseMessage;
}
?>
</body>
</html>



UTILICE LOS MISMOS DATOS DE SUS EJEMPLOS Y ME LANZA ESE ERROR, POR FAVOR NECESITO DE SU AYUDA
MI CORREO:
jaimeir...@gmail.com

ADMIN

unread,
Apr 15, 2016, 6:36:28 PM4/15/16
to Desarrolladores PayU Latam
Buenas tardes Jaime,

De antemano te agradecemos el hacer uso de nuestro foro para publicar tus dudas.

Este error se presenta debido a que la variable referenceCode debe ser única para cada orden. En el caso de tu ejemplo, la variable tiene el valor "payment_test_00000001" y cuando vas a generar el siguiente pago, al existir previamente esta referencia, se genera error.
La recomendación que nosotros te hacemos es utilizar una función de tiempo, de tal forma que cada vez la referencia será diferente, como se muestra a continuación:
$reference = time();

Esperamos que la información haya sido de utilidad.

Angel Roman

unread,
Mar 10, 2017, 10:37:06 AM3/10/17
to Desarrolladores PayU Latam
Hola,

Se que esta conversación es antigua pero quisiera saber si me pueden ayudar con la misma situación, poder generar referencias diferentes para cada proceso de pago.

¿En dónde se debe de agregar el código PHP que mencionan? No se casi nada de programación :(

Gracias.
Reply all
Reply to author
Forward
0 new messages