Queries SDK
To integrate with Queries SDK, target the requests to the following URLs:
// URL for test: https://sandbox.api.payulatam.com/payments-api/
PayU.paymentsUrl = “https://api.payulatam.com/payments-api/”;
// URL for test: https://sandbox.api.payulatam.com/reports-api/
PayU.reportsUrl = “https://api.payulatam.com/reports-api/”;
// URL for test: https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi
Environment::setPaymentsCustomUrl(“https://api.payulatam.com/payments-api/4.0/service.cgi”);
// URL for test: https://sandbox.api.payulatam.com/reports-api/4.0/service.cgi
Environment::setReportsCustomUrl(“https://api.payulatam.com/reports-api/4.0/service.cgi”);
Available methods
Queries SDK includes the following methods:
Query by Order Id
Order Id is a value generated by PayU to identify all the transactions generated for a payment request performed by your customer. You can use the getOrderDetail
command to consult the status of an Order by its identifier.
The following examples show how to call the method for this transaction type according to the programming language.
Map<String, String> parameters = new HashMap<String, String>();
// Enter the order’s reference code here.
parameters.put(PayU.PARAMETERS.ORDER_ID, "857817550");
Order response = PayUReports.getOrderDetail(parameters);
// -- obtain the order’s properties --
if(response != null){
response.getAccountId();
response.getStatus();
response.getReferenceCode();
response.getAdditionalValue("TX_VALUE").getValue();
response.getAdditionalValue("TX_TAX").getValue();
if(response.getBuyer() != null){
response.getBuyer().getEmailAddress();
response.getBuyer().getFullName();
}
// -- go through the transactions that are associated to the order--
List<Transaction> transactions = response.getTransactions();
Iterator<Transaction> transactions_iterator = transactions.iterator();
while(transactions_iterator.hasNext()){
Transaction transaction= (Transaction) transactions_iterator.next();
transaction.getType();
transaction.getTransactionResponse().getState();
transaction.getTransactionResponse().getPaymentNetworkResponseCode();
transaction.getTransactionResponse().getTrazabilityCode();
transaction.getTransactionResponse().getResponseCode();
if(transaction.getPayer() != null){
transaction.getPayer().getFullName();
transaction.getPayer().getEmailAddress();
}
}
}
// Enter the order’s reference code here.
$parameters = array(PayUParameters::ORDER_ID => "44469220");
$order = PayUReports::getOrderDetail($parameters);
if ($order) {
$order->accountId;
$order->status;
$order->referenceCode;
$order->additionalValues->TX_VALUE->value;
$order->additionalValues->TX_TAX->value;
if ($order->buyer) {
$order->buyer->emailAddress;
$order->buyer->fullName;
}
$transactions=$order->transactions;
foreach ($transactions as $transaction) {
$transaction->type;
$transaction->transactionResponse->state;
$transaction->transactionResponse->paymentNetworkResponseCode;
$transaction->transactionResponse->trazabilityCode;
$transaction->transactionResponse->responseCode;
if ($transaction->payer) {
$transaction->payer->fullName;
$transaction->payer->emailAddress;
}
}
}
Query by Transaction Id
Transaction Id is a value generated by PayU to identify one transaction generated for an order.
You can use the getTransactionResponse
command to consult the information of a given transaction.
The following examples show how to call the method for this transaction type according to the programming language.
Map<String, String> parameters = new HashMap<String, String>();
// Enter the transaction identifier here.
parameters.put(PayU.PARAMETERS.TRANSACTION_ID, "3310ba3b-cf64-49b2-80e6-3f9196917131");
TransactionResponse response = PayUReports.getTransactionResponse(parameters);
// --you will be able to obtain the properties of the response --
if(response != null){
response.getState();
response.getTrazabilityCode();
response.getAuthorizationCode();
response.getResponseCode();
response.getOperationDate();
}
$parameters = array(PayUParameters::TRANSACTION_ID => "3310ba3b-cf64-49b2-80e6-3f9196917131");
$response = PayUReports::getTransactionResponse($parameters);
if ($response) {
$response->state;
$response->trazabilityCode;
$response->authorizationCode;
$response->responseCode;
$response->operationDate;
}
Query by Reference Id
Reference Id is a value generated by your commerce to identify an order.
You can use the getOrderDetailByReferenceCode
to consult the status of an Order by your own order identifier (reference).
The following examples show how to call the method for this transaction type according to the programming language.
Map<String, String> parameters = new HashMap<String, String>();
// Enter the order’s reference code here.
parameters.put(PayU.PARAMETERS.REFERENCE_CODE, "payment_test_1625093692957");
List<Order> orders_response = PayUReports.getOrderDetailByReferenceCode(parameters);
Iterator<Order> orders_iterator= orders_response.iterator();
// -- go through the orders with the queried reference--
while(orders_iterator.hasNext()){
Order order= (Order) orders_iterator.next();
if(order != null){
order.getAccountId();
order.getStatus();
order.getReferenceCode();
order.getAdditionalValue("TX_VALUE").getValue();
order.getAdditionalValue("TX_TAX").getValue();
if(order.getBuyer() != null){
order.getBuyer().getEmailAddress();
order.getBuyer().getFullName();
}
// -- go through the transactions associated to the order--
List<Transaction> transactions=order.getTransactions();
Iterator<Transaction> transactions_iterator=transactions.iterator();
while(transactions_iterator.hasNext()){
Transaction transaction= (Transaction) transactions_iterator.next();
transaction.getType();
transaction.getTransactionResponse().getState();
transaction.getTransactionResponse().getPaymentNetworkResponseCode();
transaction.getTransactionResponse().getTrazabilityCode();
transaction.getTransactionResponse().getResponseCode();
if(transaction.getPayer() != null){
transaction.getPayer().getFullName();
transaction.getPayer().getEmailAddress();
}
}
}
}
// Enter the order’s reference code here.
$parameters = array(PayUParameters::REFERENCE_CODE => "payment_test_1625093692957");
$response = PayUReports::getOrderDetailByReferenceCode($parameters);
foreach ($response as $order) {
$order->accountId;
$order->status;
$order->referenceCode;
$order->additionalValues->TX_VALUE->value;
$order->additionalValues->TX_TAX->value;
if ($order->buyer) {
$order->buyer->emailAddress;
$order->buyer->fullName;
}
$transactions=$order->transactions;
foreach ($transactions as $transaction) {
$transaction->type;
$transaction->transactionResponse->state;
$transaction->transactionResponse->paymentNetworkResponseCode;
$transaction->transactionResponse->trazabilityCode;
$transaction->transactionResponse->responseCode;
if ($transaction->payer) {
$transaction->payer->fullName;
$transaction->payer->emailAddress;
}
}
}
Ping
The PING
method lets you verify the connection to our platform. The following examples show how to call the method for this transaction type according to the programming language.
boolean response = PayUReports.doPing();
LoggerUtil.info("{0}", response);
$response = PayUReports::doPing();
$response -> code;