Payments SDK - Peru
To integrate with Payments SDK Peru, 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
Payments SDK includes the following methods:
- Submit transaction with credit card
- Submit transaction with cash
- Available payment methods query
- Ping
Note
To confirm the status of a transaction, you can use the Queries SDK.Submit transaction with credit card
This method lets you process the payments performed by your customers using credit cards. For Peru, you can perform the two-step flows (Authorization, Capture), and one-step flows (Charge). For more information, refer to Payment flows.
Considerations
- Send a valid Credit card Payment Method in the request, see the available Payment Methods for Peru.
- For payments with credit card tokens, set the parameters
TOKEN_ID
andCREDIT_CARD_SECURITY_CODE
(if you process with security code) replacing the information of the credit card. For more information, refer to Tokenization SDK. - By default, processing credit cards without security code is not enabled. If you want to enable this feature, contact your Sales representative. After this feature is enabled for you, set the parameter
PROCESS_WITHOUT_CVV2
as true and remove the parameterCREDIT_CARD_SECURITY_CODE
. - In Peru, you can select 0 or 2 to 36 installments when paying with credit card. If you select one (1) installment, PayU sends zero (0) as default value.
Authorization
Use this method to perform the Authorization step of a two-step flow. In this step, you authorize the payment but the amount is not debited until you capture the funds.
The following examples show how to call the method for this transaction type according to the programming language.
String reference = "payment_test_00000001";
String value= "100";
Map<String, String> parameters = new HashMap<String, String>();
// Enter the account’s identifier here.
parameters.put(PayU.PARAMETERS.ACCOUNT_ID, "512323");
// Enter the reference code here.
parameters.put(PayU.PARAMETERS.REFERENCE_CODE, ""+reference);
// Enter the description here.
parameters.put(PayU.PARAMETERS.DESCRIPTION, "payment test");
// Enter the transaction language here.
parameters.put(PayU.PARAMETERS.LANGUAGE, "Language.es");
// -- Values --
// Enter the value here.
parameters.put(PayU.PARAMETERS.VALUE, ""+value);
// Enter the currency here.
parameters.put(PayU.PARAMETERS.CURRENCY, ""+Currency.PEN.name());
// -- Buyer --
// Enter the buyer Id here.
parameters.put(PayU.PARAMETERS.BUYER_ID, "1");
// Enter the buyer's name here.
parameters.put(PayU.PARAMETERS.BUYER_NAME, "First name and second buyer name");
// Enter the buyer's e-mail here
parameters.put(PayU.PARAMETERS.BUYER_EMAIL, "buyer_test@test.com");
// Enter the buyer's contact phone here.
parameters.put(PayU.PARAMETERS.BUYER_CONTACT_PHONE, "7563126");
// Enter the buyer's contact document here.
parameters.put(PayU.PARAMETERS.BUYER_DNI, "123456789");
// Enter the buyer's address here.
parameters.put(PayU.PARAMETERS.BUYER_STREET, "Av. Isabel La Católica 103-La Victoria");
parameters.put(PayU.PARAMETERS.BUYER_STREET_2, "5555487");
parameters.put(PayU.PARAMETERS.BUYER_CITY, "Lima");
parameters.put(PayU.PARAMETERS.BUYER_STATE, "Lima y Callao");
parameters.put(PayU.PARAMETERS.BUYER_COUNTRY, "PE");
parameters.put(PayU.PARAMETERS.BUYER_POSTAL_CODE, "000000");
parameters.put(PayU.PARAMETERS.BUYER_PHONE, "7563126");
// -- Payer --
// Enter the payer's ID here.
parameters.put(PayU.PARAMETERS.PAYER_ID, "1");
// Enter the payer's name here.
parameters.put(PayU.PARAMETERS.PAYER_NAME, "First name and second payer name");
// Enter the payer's e-mail here.
parameters.put(PayU.PARAMETERS.PAYER_EMAIL, "payer_test@test.com");
// Enter the payer's contact phone here.
parameters.put(PayU.PARAMETERS.PAYER_CONTACT_PHONE, "7563126");
// Enter the payer's contact document here.
parameters.put(PayU.PARAMETERS.PAYER_DNI, "5415668464654");
// Enter the payer's address here.
parameters.put(PayU.PARAMETERS.PAYER_STREET, "Av. Isabel La Católica 103-La Victoria");
parameters.put(PayU.PARAMETERS.PAYER_STREET_2, "5555487");
parameters.put(PayU.PARAMETERS.PAYER_CITY, "Lima");
parameters.put(PayU.PARAMETERS.PAYER_STATE, "Lima y Callao");
parameters.put(PayU.PARAMETERS.PAYER_COUNTRY, "PE");
parameters.put(PayU.PARAMETERS.PAYER_POSTAL_CODE, "000000");
parameters.put(PayU.PARAMETERS.PAYER_PHONE, "7563126");
// -- Credit card data --
// Enter the number of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_NUMBER, "4097440000000004");
// Enter expiration date of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_EXPIRATION_DATE, "2022/12");
// Enter the security code of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_SECURITY_CODE, "321");
// Enter the name of the credit card here
parameters.put(PayU.PARAMETERS.PAYMENT_METHOD, "VISA");
// Enter the number of installments here.
parameters.put(PayU.PARAMETERS.INSTALLMENTS_NUMBER, "1");
// Enter the name of the country here.
parameters.put(PayU.PARAMETERS.COUNTRY, PaymentCountry.PE.name());
// Device Session ID
parameters.put(PayU.PARAMETERS.DEVICE_SESSION_ID, "vghs6tvkcle931686k1900o6e1");
// Payer IP
parameters.put(PayU.PARAMETERS.IP_ADDRESS, "127.0.0.1");
// Cookie of the current session.
parameters.put(PayU.PARAMETERS.COOKIE, "pt1t38347bs6jc9ruv2ecpv7o2");
// User agent of the current session.
parameters.put(PayU.PARAMETERS.USER_AGENT, "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0");
// Authorization request
TransactionResponse response = PayUPayments.doAuthorization(parameters);
// You can obtain the properties in the response
if(response != null){
response.getOrderId();
response.getTransactionId();
response.getState();
if(response.getState().toString().equalsIgnoreCase("PENDING")){
response.getPendingReason();
}
response.getPaymentNetworkResponseCode();
response.getPaymentNetworkResponseErrorMessage();
response.getTrazabilityCode();
response.getResponseCode();
response.getResponseMessage();
}
$reference = "payment_test_00000001";
$value = "100";
$parameters = array(
// Enter the account’s identifier here
PayUParameters::ACCOUNT_ID => "512323",
// Enter the reference code here.
PayUParameters::REFERENCE_CODE => $reference,
// Enter the description here.
PayUParameters::DESCRIPTION => "payment test",
// -- Values --
// Enter the value here.
PayUParameters::VALUE => $value,
// Enter the currency here.
PayUParameters::CURRENCY => "PEN",
// -- Buyer --
// Enter the buyer Id here.
PayUParameters::BUYER_ID => "1",
// Enter the buyer's name here.
PayUParameters::BUYER_NAME => "First name and second buyer name",
// Enter the buyer's e-mail here.
PayUParameters::BUYER_EMAIL => "buyer_test@test.com",
// Enter the buyer's contact phone here.
PayUParameters::BUYER_CONTACT_PHONE => "7563126",
// Enter the buyer's contact document here.
PayUParameters::BUYER_DNI => "5415668464654",
// Enter the buyer's address here.
PayUParameters::BUYER_STREET => "Av. Isabel La Católica 103-La Victoria",
PayUParameters::BUYER_STREET_2 => "5555487",
PayUParameters::BUYER_CITY => "Lima",
PayUParameters::BUYER_STATE => "Lima y Callao",
PayUParameters::BUYER_COUNTRY => "PE",
PayUParameters::BUYER_POSTAL_CODE => "000000",
PayUParameters::BUYER_PHONE => "7563126",
// -- Payer --
// Enter the payer's ID here.
PayUParameters::PARAMETERS.PAYER_ID => "1",
/// Enter the payer's name here
PayUParameters::PAYER_NAME => "First name and second payer name",
// Enter the payer's e-mail here
PayUParameters::PAYER_EMAIL => "payer_test@test.com",
// Enter the payer's contact phone here.
PayUParameters::PAYER_CONTACT_PHONE => "7563126",
// Enter the payer's contact document here.
PayUParameters::PAYER_DNI => "5415668464654",
// Enter the payer's DNI type here
PayUParameters::PARAMETERS.PAYER_DNI_TYPE => "DNI",
// Enter the payer's address here.
PayUParameters::PAYER_STREET => "Av. Isabel La Católica 103-La Victoria",
PayUParameters::PAYER_STREET_2 => "5555487",
PayUParameters::PAYER_CITY => "Lima",
PayUParameters::PAYER_STATE => "Lima y Callao",
PayUParameters::PAYER_COUNTRY => "PE",
PayUParameters::PAYER_POSTAL_CODE => "000000",
PayUParameters::PAYER_PHONE => "7563126",
// -- Credit card data --
// Enter the number of the credit card here
PayUParameters::CREDIT_CARD_NUMBER => "4097440000000004",
// Enter expiration date of the credit card here
PayUParameters::CREDIT_CARD_EXPIRATION_DATE => "2022/12",
// Enter the security code of the credit card here
PayUParameters::CREDIT_CARD_SECURITY_CODE=> "321",
// Enter the name of the credit card here
PayUParameters::PAYMENT_METHOD => "VISA",
// Enter the number of installments here.
PayUParameters::INSTALLMENTS_NUMBER => "1",
// Enter the name of the country here.
PayUParameters::COUNTRY => PayUCountries::PE,
// Device Session ID
PayUParameters::DEVICE_SESSION_ID => "vghs6tvkcle931686k1900o6e1",
// Payer IP
PayUParameters::IP_ADDRESS => "127.0.0.1",
// Cookie of the current session
PayUParameters::PAYER_COOKIE=>"pt1t38347bs6jc9ruv2ecpv7o2",
// User agent of the current session
PayUParameters::USER_AGENT=>"Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"
);
// Authorization request
$response = PayUPayments::doAuthorization($parameters);
// You can obtain the properties in the response
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;
}
Capture
Use this method to perform the Capture step of a two-step flow. In this step, you capture the funds previously Authorized to transfer them to your PayU account.
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 identifier here.
parameters.put(PayU.PARAMETERS.ORDER_ID, "1400469408");
// Enter the transaction identifier here.
parameters.put(PayU.PARAMETERS.TRANSACTION_ID, "143b2fcf-4dff-4fa0-a0c9-9409be949dd4");
// Enter the transaction language here.
parameters.put(PayU.PARAMETERS.LANGUAGE, "Language.es");
// Capture Request
TransactionResponse response = PayUPayments.doCapture(parameters);
// Response
if(response != null){
response.getOrderId();
response.getTransactionId();
response.getState();
response.getPaymentNetworkResponseCode();
response.getPaymentNetworkResponseErrorMessage();
response.getTrazabilityCode();
response.getResponseCode();
response.getResponseMessage();
}
$parameters = array(
// Enter the account’s identifier here.
PayUParameters::ACCOUNT_ID => "512322",
// Enter the order identifier here.
PayUParameters::ORDER_ID => "1400469408",
// Enter the transaction identifier here.
PayUParameters::TRANSACTION_ID => "143b2fcf-4dff-4fa0-a0c9-9409be949dd4",
);
$response = PayUPayments::doCapture($parameters);
if ($response) {
$response->transactionResponse->orderId;
$response->transactionResponse->transactionId;
$response->transactionResponse->state;
$response->transactionResponse->paymentNetworkResponseCode;
$response->transactionResponse->paymentNetworkResponseErrorMessage;
$response->transactionResponse->trazabilityCode;
$response->transactionResponse->responseCode;
$response->transactionResponse->responseMessage;
}
Charge
Use this method to perform a one-step flow, namely a charge. In this step, both steps of the two-step flow are combined in a single transaction and the funds are transferred from the customers account to your PayU account once they have been approved:
The following examples show how to call the method for this transaction type according to the programming language.
String reference = "payment_test_00000001";
String value= "100";
Map<String, String> parameters = new HashMap<String, String>();
// Enter the account’s identifier here.
parameters.put(PayU.PARAMETERS.ACCOUNT_ID, "512323");
// Enter the reference code here.
parameters.put(PayU.PARAMETERS.REFERENCE_CODE, ""+reference);
// Enter the description here.
parameters.put(PayU.PARAMETERS.DESCRIPTION, "payment test");
// Enter the transaction language here.
parameters.put(PayU.PARAMETERS.LANGUAGE, "Language.es");
// -- Values --
// Enter the value here.
parameters.put(PayU.PARAMETERS.VALUE, ""+value);
// Enter the currency here.
parameters.put(PayU.PARAMETERS.CURRENCY, ""+Currency.PEN.name());
// -- Buyer --
// Enter the buyer Id here.
parameters.put(PayU.PARAMETERS.BUYER_ID, "1");
// Enter the buyer's name here.
parameters.put(PayU.PARAMETERS.BUYER_NAME, "First name and second buyer name");
// Enter the buyer's e-mail here
parameters.put(PayU.PARAMETERS.BUYER_EMAIL, "buyer_test@test.com");
// Enter the buyer's contact phone here.
parameters.put(PayU.PARAMETERS.BUYER_CONTACT_PHONE, "7563126");
// Enter the buyer's contact document here.
parameters.put(PayU.PARAMETERS.BUYER_DNI, "123456789");
// Enter the buyer's address here.
parameters.put(PayU.PARAMETERS.BUYER_STREET, "Av. Isabel La Católica 103-La Victoria");
parameters.put(PayU.PARAMETERS.BUYER_STREET_2, "5555487");
parameters.put(PayU.PARAMETERS.BUYER_CITY, "Lima");
parameters.put(PayU.PARAMETERS.BUYER_STATE, "Lima y Callao");
parameters.put(PayU.PARAMETERS.BUYER_COUNTRY, "PE");
parameters.put(PayU.PARAMETERS.BUYER_POSTAL_CODE, "000000");
parameters.put(PayU.PARAMETERS.BUYER_PHONE, "7563126");
// -- Payer --
// Enter the payer's ID here.
parameters.put(PayU.PARAMETERS.PAYER_ID, "1");
// Enter the payer's name here.
parameters.put(PayU.PARAMETERS.PAYER_NAME, "First name and second payer name");
// Enter the payer's e-mail here.
parameters.put(PayU.PARAMETERS.PAYER_EMAIL, "payer_test@test.com");
// Enter the payer's contact phone here.
parameters.put(PayU.PARAMETERS.PAYER_CONTACT_PHONE, "7563126");
// Enter the payer's contact document here.
parameters.put(PayU.PARAMETERS.PAYER_DNI, "5415668464654");
// Enter the payer's address here.
parameters.put(PayU.PARAMETERS.PAYER_STREET, "Av. Isabel La Católica 103-La Victoria");
parameters.put(PayU.PARAMETERS.PAYER_STREET_2, "5555487");
parameters.put(PayU.PARAMETERS.PAYER_CITY, "Lima");
parameters.put(PayU.PARAMETERS.PAYER_STATE, "Lima y Callao");
parameters.put(PayU.PARAMETERS.PAYER_COUNTRY, "PE");
parameters.put(PayU.PARAMETERS.PAYER_POSTAL_CODE, "000000");
parameters.put(PayU.PARAMETERS.PAYER_PHONE, "7563126");
// -- Credit card data --
// Enter the number of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_NUMBER, "4097440000000004");
// Enter expiration date of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_EXPIRATION_DATE, "2022/12");
// Enter the security code of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_SECURITY_CODE, "321");
// Enter the name of the credit card here
parameters.put(PayU.PARAMETERS.PAYMENT_METHOD, "VISA");
// Enter the number of installments here.
parameters.put(PayU.PARAMETERS.INSTALLMENTS_NUMBER, "1");
// Enter the name of the country here.
parameters.put(PayU.PARAMETERS.COUNTRY, PaymentCountry.PE.name());
// Device Session ID
parameters.put(PayU.PARAMETERS.DEVICE_SESSION_ID, "vghs6tvkcle931686k1900o6e1");
// Payer IP
parameters.put(PayU.PARAMETERS.IP_ADDRESS, "127.0.0.1");
// Cookie of the current session.
parameters.put(PayU.PARAMETERS.COOKIE, "pt1t38347bs6jc9ruv2ecpv7o2");
// User agent of the current session.
parameters.put(PayU.PARAMETERS.USER_AGENT, "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0");
// Authorization request
TransactionResponse response = PayUPayments.doAuthorizationAndCapture(parameters);
// You can obtain the properties in the response
if(response != null){
response.getOrderId();
response.getTransactionId();
response.getState();
if(response.getState().toString().equalsIgnoreCase("PENDING")){
response.getPendingReason();
}
response.getPaymentNetworkResponseCode();
response.getPaymentNetworkResponseErrorMessage();
response.getTrazabilityCode();
response.getResponseCode();
response.getResponseMessage();
}
$reference = "payment_test_00000001";
$value = "100";
$parameters = array(
// Enter the account’s identifier here
PayUParameters::ACCOUNT_ID => "512323",
// Enter the reference code here.
PayUParameters::REFERENCE_CODE => $reference,
// Enter the description here.
PayUParameters::DESCRIPTION => "payment test",
// -- Values --
// Enter the value here.
PayUParameters::VALUE => $value,
// Enter the currency here.
PayUParameters::CURRENCY => "PEN",
// -- Buyer --
// Enter the buyer Id here.
PayUParameters::BUYER_ID => "1",
// Enter the buyer's name here.
PayUParameters::BUYER_NAME => "First name and second buyer name",
// Enter the buyer's e-mail here.
PayUParameters::BUYER_EMAIL => "buyer_test@test.com",
// Enter the buyer's contact phone here.
PayUParameters::BUYER_CONTACT_PHONE => "7563126",
// Enter the buyer's contact document here.
PayUParameters::BUYER_DNI => "5415668464654",
// Enter the buyer's address here.
PayUParameters::BUYER_STREET => "Av. Isabel La Católica 103-La Victoria",
PayUParameters::BUYER_STREET_2 => "5555487",
PayUParameters::BUYER_CITY => "Lima",
PayUParameters::BUYER_STATE => "Lima y Callao",
PayUParameters::BUYER_COUNTRY => "PE",
PayUParameters::BUYER_POSTAL_CODE => "000000",
PayUParameters::BUYER_PHONE => "7563126",
// -- Payer --
// Enter the payer's ID here.
PayUParameters::PARAMETERS.PAYER_ID => "1",
/// Enter the payer's name here
PayUParameters::PAYER_NAME => "First name and second payer name",
// Enter the payer's e-mail here
PayUParameters::PAYER_EMAIL => "payer_test@test.com",
// Enter the payer's contact phone here.
PayUParameters::PAYER_CONTACT_PHONE => "7563126",
// Enter the payer's contact document here.
PayUParameters::PAYER_DNI => "5415668464654",
// Enter the payer's DNI type here
PayUParameters::PARAMETERS.PAYER_DNI_TYPE => "DNI",
// Enter the payer's address here.
PayUParameters::PAYER_STREET => "Av. Isabel La Católica 103-La Victoria",
PayUParameters::PAYER_STREET_2 => "5555487",
PayUParameters::PAYER_CITY => "Lima",
PayUParameters::PAYER_STATE => "Lima y Callao",
PayUParameters::PAYER_COUNTRY => "PE",
PayUParameters::PAYER_POSTAL_CODE => "000000",
PayUParameters::PAYER_PHONE => "7563126",
// -- Credit card data --
// Enter the number of the credit card here
PayUParameters::CREDIT_CARD_NUMBER => "4097440000000004",
// Enter expiration date of the credit card here
PayUParameters::CREDIT_CARD_EXPIRATION_DATE => "2022/12",
// Enter the security code of the credit card here
PayUParameters::CREDIT_CARD_SECURITY_CODE=> "321",
// Enter the name of the credit card here
PayUParameters::PAYMENT_METHOD => "VISA",
// Enter the number of installments here.
PayUParameters::INSTALLMENTS_NUMBER => "1",
// Enter the name of the country here.
PayUParameters::COUNTRY => PayUCountries::PE,
// Device Session ID
PayUParameters::DEVICE_SESSION_ID => "vghs6tvkcle931686k1900o6e1",
// Payer IP
PayUParameters::IP_ADDRESS => "127.0.0.1",
// Cookie of the current session
PayUParameters::PAYER_COOKIE=>"pt1t38347bs6jc9ruv2ecpv7o2",
// User agent of the current session
PayUParameters::USER_AGENT=>"Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"
);
// Authorization request
$response = PayUPayments::doAuthorizationAndCapture($parameters);
// You can obtain the properties in the response
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;
}
Submit transaction with cash
This method lets you process the payments in cash of your customers. To integrate with cash transactions, you must redirect the customer to the URL found in the response of the method; your customer sees a payment receipt like this.
Considerations
- The parameter
EXPIRATION_DATE
is not mandatory. If you don’t send this parameter, its default value is seven (7) days after the current date.
If you send a date later than the default number of days, PayU will ignore this value and the expiration will be set as default. - The extra parameters have the following data related to the transaction:
- REFERENCE: internal payment reference generated by PayU.
- EXPIRATION_DATE: maximum term for the payer to perform the payment.
- BAR_CODE: barcode which lets the payer perform the payment.
- URL_PAYMENT_RECEIPT_HTML: payment receipt in HTML format. This is where you need to redirect the payment when the payer selects cash payment.
- URL_PAYMENT_RECEIPT_PDF: payment receipt in PDF format.
Method call
The following examples show how to call the method for this transaction type according to the programming language.
String reference = "payment_test_00000001";
String value= "100";
Map<String, String> parameters = new HashMap<String, String>();
// Enter the account’s identifier here.
parameters.put(PayU.PARAMETERS.ACCOUNT_ID, "512323");
// Enter the reference code here.
parameters.put(PayU.PARAMETERS.REFERENCE_CODE, ""+reference);
// Enter the description here.
parameters.put(PayU.PARAMETERS.DESCRIPTION, "payment test");
// Enter the transaction language here.
parameters.put(PayU.PARAMETERS.LANGUAGE, "Language.es");
// -- Values --
// Enter the value here.
parameters.put(PayU.PARAMETERS.VALUE, ""+value);
// Enter the currency here.
parameters.put(PayU.PARAMETERS.CURRENCY, ""+Currency.PEN.name());
// -- Buyer --
// Enter the buyer Id here.
parameters.put(PayU.PARAMETERS.BUYER_ID, "1");
// Enter the buyer's name here.
parameters.put(PayU.PARAMETERS.BUYER_NAME, "First name and second buyer name");
// Enter the buyer's e-mail here
parameters.put(PayU.PARAMETERS.BUYER_EMAIL, "buyer_test@test.com");
// Enter the buyer's contact phone here.
parameters.put(PayU.PARAMETERS.BUYER_CONTACT_PHONE, "7563126");
// Enter the buyer's contact document here.
parameters.put(PayU.PARAMETERS.BUYER_DNI, "123456789");
// Enter the buyer's address here.
parameters.put(PayU.PARAMETERS.BUYER_STREET, "Av. Isabel La Católica 103-La Victoria");
parameters.put(PayU.PARAMETERS.BUYER_STREET_2, "5555487");
parameters.put(PayU.PARAMETERS.BUYER_CITY, "Lima");
parameters.put(PayU.PARAMETERS.BUYER_STATE, "Lima y Callao");
parameters.put(PayU.PARAMETERS.BUYER_COUNTRY, "PE");
parameters.put(PayU.PARAMETERS.BUYER_POSTAL_CODE, "000000");
parameters.put(PayU.PARAMETERS.BUYER_PHONE, "7563126");
// -- Payer --
// Enter the payer's ID here.
parameters.put(PayU.PARAMETERS.PAYER_ID, "1");
// Enter the payer's name here.
parameters.put(PayU.PARAMETERS.PAYER_NAME, "First name and second payer name");
// Enter the payer's e-mail here.
parameters.put(PayU.PARAMETERS.PAYER_EMAIL, "payer_test@test.com");
// Enter the payer's contact phone here.
parameters.put(PayU.PARAMETERS.PAYER_CONTACT_PHONE, "7563126");
// Enter the payer's contact document here.
parameters.put(PayU.PARAMETERS.PAYER_DNI, "5415668464654");
// Enter the payer's address here.
parameters.put(PayU.PARAMETERS.PAYER_STREET, "Av. Isabel La Católica 103-La Victoria");
parameters.put(PayU.PARAMETERS.PAYER_STREET_2, "5555487");
parameters.put(PayU.PARAMETERS.PAYER_CITY, "Lima");
parameters.put(PayU.PARAMETERS.PAYER_STATE, "Lima y Callao");
parameters.put(PayU.PARAMETERS.PAYER_COUNTRY, "PE");
parameters.put(PayU.PARAMETERS.PAYER_POSTAL_CODE, "000000");
parameters.put(PayU.PARAMETERS.PAYER_PHONE, "7563126");
// Enter the name of the cash payment here
parameters.put(PayU.PARAMETERS.PAYMENT_METHOD, "PAGOEFECTIVO");
// Enter the payment due date
parameters.put(PayU.PARAMETERS.EXPIRATION_DATE, "2021-07-01T20:00:00");
// Enter the name of the country here.
parameters.put(PayU.PARAMETERS.COUNTRY, PaymentCountry.PE.name());
// Payer IP
parameters.put(PayU.PARAMETERS.IP_ADDRESS, "127.0.0.1");
// Authorization request
TransactionResponse response = PayUPayments.doAuthorizationAndCapture(parameters);
// You can obtain the properties in the response
if(response != null){
response.getOrderId();
response.getTransactionId();
response.getState();
if(response.getState().toString().equalsIgnoreCase("PENDING")){
response.getPendingReason();
Map extraParameters = response.getExtraParameters();
// Obtain the payment receipt URL
int reference = (Integer)extraParameters.get("REFERENCE");
String pdf = (String)extraParameters.get("URL_PAYMENT_RECEIPT_PDF");
Date date = (Date)extraParameters.get("EXPIRATION_DATE");
String barCode = (String)extraParameters.get("BAR_CODE");
String url = (String)extraParameters.get("URL_PAYMENT_RECEIPT_HTML");
}
response.getPaymentNetworkResponseCode();
response.getPaymentNetworkResponseErrorMessage();
response.getTrazabilityCode();
response.getResponseCode();
response.getResponseMessage();
}
$reference = "payment_test_00000001";
$value = "100";
$parameters = array(
// Enter the account’s identifier here
PayUParameters::ACCOUNT_ID => "512323",
// Enter the reference code here.
PayUParameters::REFERENCE_CODE => $reference,
// Enter the description here.
PayUParameters::DESCRIPTION => "payment test",
// -- Values --
// Enter the value here.
PayUParameters::VALUE => $value,
// Enter the currency here.
PayUParameters::CURRENCY => "PEN",
// -- Buyer --
// Enter the buyer Id here.
PayUParameters::BUYER_ID => "1",
// Enter the buyer's name here.
PayUParameters::BUYER_NAME => "First name and second buyer name",
// Enter the buyer's e-mail here.
PayUParameters::BUYER_EMAIL => "buyer_test@test.com",
// Enter the buyer's contact phone here.
PayUParameters::BUYER_CONTACT_PHONE => "7563126",
// Enter the buyer's contact document here.
PayUParameters::BUYER_DNI => "5415668464654",
// Enter the buyer's address here.
PayUParameters::BUYER_STREET => "Av. Isabel La Católica 103-La Victoria",
PayUParameters::BUYER_STREET_2 => "5555487",
PayUParameters::BUYER_CITY => "Lima",
PayUParameters::BUYER_STATE => "Lima y Callao",
PayUParameters::BUYER_COUNTRY => "PE",
PayUParameters::BUYER_POSTAL_CODE => "000000",
PayUParameters::BUYER_PHONE => "7563126",
// -- Payer --
// Enter the payer's ID here.
PayUParameters::PARAMETERS.PAYER_ID => "1",
/// Enter the payer's name here
PayUParameters::PAYER_NAME => "First name and second payer name",
// Enter the payer's e-mail here
PayUParameters::PAYER_EMAIL => "payer_test@test.com",
// Enter the payer's contact phone here.
PayUParameters::PAYER_CONTACT_PHONE => "7563126",
// Enter the payer's contact document here.
PayUParameters::PAYER_DNI => "5415668464654",
// Enter the payer's DNI type here
PayUParameters::PARAMETERS.PAYER_DNI_TYPE => "DNI",
// Enter the payer's address here.
PayUParameters::PAYER_STREET => "Av. Isabel La Católica 103-La Victoria",
PayUParameters::PAYER_STREET_2 => "5555487",
PayUParameters::PAYER_CITY => "Lima",
PayUParameters::PAYER_STATE => "Lima y Callao",
PayUParameters::PAYER_COUNTRY => "PE",
PayUParameters::PAYER_POSTAL_CODE => "000000",
PayUParameters::PAYER_PHONE => "7563126",
// -- Credit card data --
// Enter the number of the credit card here
PayUParameters::CREDIT_CARD_NUMBER => "4097440000000004",
// Enter expiration date of the credit card here
PayUParameters::CREDIT_CARD_EXPIRATION_DATE => "2022/12",
// Enter the security code of the credit card here
PayUParameters::CREDIT_CARD_SECURITY_CODE=> "321",
// Enter the name of the credit card here
PayUParameters::PAYMENT_METHOD => "PAGOEFECTIVO",
// Enter the payment due date
PayUParameters::EXPIRATION_DATE => "2021-07-01T20:00:00",
// Enter the name of the country here.
PayUParameters::COUNTRY => PayUCountries::PE,
// Payer IP
PayUParameters::IP_ADDRESS => "127.0.0.1"
);
// Authorization request
$response = PayUPayments::doAuthorizationAndCapture($parameters);
// You can obtain the properties in the response
if ($response) {
$response->transactionResponse->orderId;
$response->transactionResponse->transactionId;
$response->transactionResponse->state;
if ($response->transactionResponse->state=="PENDING"){
$response->transactionResponse->pendingReason;
$response->transactionResponse->trazabilityCode;
$response->transactionResponse->authorizationCode;
$response->transactionResponse->extraParameters->REFERENCE;
$response->transactionResponse->extraParameters->URL_PAYMENT_RECEIPT_PDF;
$response->transactionResponse->extraParameters->EXPIRATION_DATE;
$response->transactionResponse->extraParameters->BAR_CODE;
$response->transactionResponse->extraParameters->URL_PAYMENT_RECEIPT_HTML;
}
$response->transactionResponse->paymentNetworkResponseCode;
$response->transactionResponse->paymentNetworkResponseErrorMessage;
$response->transactionResponse->trazabilityCode;
$response->transactionResponse->responseCode;
$response->transactionResponse->responseMessage;
}
Available payment methods query
This method returns a list of the payment methods available in all countries.
Method call
The following examples show how to call the method for this transaction type according to the programming language.
List<PaymentMethodComplete> response = PayUPayments.getPaymentMethods();
LoggerUtil.info("{0}", response);
$array=PayUPayments::getPaymentMethods();
$payment_methods=$array->paymentMethods;
foreach ($payment_methods as $payment_method){
$payment_method->country;
$payment_method->description;
$payment_method->id;
}
Ping
The PING
method lets you verify the connection to our platform.
Method call
The following examples show how to call the method for this transaction type according to the programming language.
boolean response = PayUPayments.doPing();
LoggerUtil.info("{0}", response);
$response = PayUPayments::doPing();
$response->code;