Tokenization SDK
Tokenization feature is available under customized commercial agreements. For more information, contact your sales representative.
To integrate with Tokenization SDK, target your request to the following URLs according to your environment.
// 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
Tokenization SDK includes methods to register and remove tokens, and methods to query tokens.
Individual credit card registration
Using this feature, you can register the information of a customer’s credit card and get a token.
Method call
The following examples show how to call the method for this transaction type according to the programming language.
//-- “Create Token” operation--
Map<String, String> parameters = new HashMap<String, String>();
// Enter the payer's name here.
parameters.put(PayU.PARAMETERS.PAYER_NAME, "Mary Keller");
// Enter the payer's ID here.
parameters.put(PayU.PARAMETERS.PAYER_ID, "10");
// Enter the payer's contact document here.
parameters.put(PayU.PARAMETERS.PAYER_DNI, "32144457");
// Enter the number of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_NUMBER, "4668063527597820");
// Enter the expiration date of the credit card here
parameters.put(PayU.PARAMETERS.CREDIT_CARD_EXPIRATION_DATE, "2024/06");
// Enter the name of the credit card here
parameters.put(PayU.PARAMETERS.PAYMENT_METHOD, "VISA");
CreditCardToken response = PayUTokens.create(parameters);
if(response != null){
response.getTokenId();
response.getMaskedNumber();
response.getPayerId();
response.getIdentificationNumber();
response.getPaymentMethod();
}
$parameters = array(
// Enter the payer's name here.
PayUParameters::PAYER_NAME => "Mary Keller",
// Enter the payer's ID here.
PayUParameters::PAYER_ID => "10",
// Enter the payer's contact document here.
PayUParameters::PAYER_DNI => "32144457",
// Enter the number of the credit card here
PayUParameters::CREDIT_CARD_NUMBER => "4668063527597820",
// Enter the expiration date of the credit card here
PayUParameters::CREDIT_CARD_EXPIRATION_DATE => "2024/10",
// Enter the name of the credit card here
PayUParameters::PAYMENT_METHOD => "VISA"
);
$response = PayUTokens::create($parameters);
if($response){
//You can obtain the credit card token
$response->creditCardToken->creditCardTokenId;
}
Individual token removal
Using this feature, you can remove the token previously registered.
Method call
The following examples show how to call the method for this transaction type according to the programming language.
// -- "Delete token" operation --
Map<String, String> parameters = new HashMap<String, String>();
// Enter the ID of the payer here.
parameters.put(PayU.PARAMETERS.PAYER_ID, "10");
// Enter the ID of the token here.
parameters.put(PayU.PARAMETERS.TOKEN_ID, "ab01ecd5-7d8f-4bee-91c1-4535d9ba282e");
CreditCardToken response = PayUTokens.remove(parameters);
LoggerUtil.info("{0}", response);
$parameters = array(
// Enter the ID of the payer here.
PayUParameters::PAYER_ID => "10",
// Enter the ID of the token here.
PayUParameters::TOKEN_ID => "ab01ecd5-7d8f-4bee-91c1-4535d9ba282e"
);
$response=PayUTokens::remove($parameters);
if($response){
}
Query tokens
Using this feature, you can get the information of tokenized credit cards, you can perform the query by the token number or by a date range.
Method call
The following examples show how to call the method for this transaction type according to the programming language.
// -- "Query token" operation --
Map<String, String> parameters = new HashMap<String, String>();
// -- Optional parameters --
// Enter the ID of the payer here.
parameters.put(PayU.PARAMETERS.PAYER_ID, "10");
// Enter the ID of the token here.
parameters.put(PayU.PARAMETERS.TOKEN_ID, "ab01ecd5-7d8f-4bee-91c1-4535d9ba282e");
// Enter the start and end date to filter in a date range.
parameters.put(PayU.PARAMETERS.START_DATE, "2021-06-29T12:00:00");
parameters.put(PayU.PARAMETERS.END_DATE, "2021-07-01T12:00:00");
List<CreditCardToken> response = PayUTokens.find(parameters);
Iterator<CreditCardToken> tokens_iterator=response.iterator();
while(tokens_iterator.hasNext()){
CreditCardToken token= (CreditCardToken) tokens_iterator.next();
token.getTokenId();
token.getMaskedNumber();
token.getPayerId();
token.getIdentificationNumber();
token.getPaymentMethod();
}
// -- Optional parameters --
$parameters = array(
// Enter the ID of the payer here.
PayUParameters::PAYER_ID => "10",
// Enter the ID of the token here.
PayUParameters::TOKEN_ID => "ab01ecd5-7d8f-4bee-91c1-4535d9ba282e",
// Enter the start and end date to filter in a date range. Optional.
PayUParameters::START_DATE=> "2021-06-29T12:00:00",
PayUParameters::END_DATE=> "2021-07-01T12:00:00"
);
$response=PayUTokens::find($parameters);
if($response) {
$credit_cards = $response->creditCardTokenList;
foreach ($credit_cards as $credit_card) {
$credit_card->creditCardTokenId;
$credit_card->maskedNumber;
$credit_card->payerId;
$credit_card->identificationNumber;
$credit_card->paymentMethod;
}
}
Payments using Tokenization
For payments with credit card tokens, include the parameter CREDIT_CARD_SECURITY_CODE
replacing the information of the credit card. The following example shows the body of the request in a high level for a one-step flow, the details of the request are not provided.
Note
To process without CVV is necessary to send the parameterPROCESS_WITHOUT_CVV2
as true in the payment request and remove the parameter CREDIT_CARD_SECURITY_CODE
.By default, processing credit cards without security code is not enabled. If you want to enable this feature, contact your Sales representative.
Map<String, String> parameters = new HashMap<String, String>();
// Enter the account’s identifier here.
parameters.put(PayU.PARAMETERS.ACCOUNT_ID, accountId);
// 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);
// -- Buyer --
// Enter the buyer information here.
//parameters.put([...], [...]);
// -- Payer --
// Enter the payer information here.
//parameters.put([...], [...]);
// -- Credit card data --
// Enter the credit card token here
parameters.put(PayU.PARAMETERS.TOKEN_ID, "ab01ecd5-7d8f-4bee-91c1-4535d9ba282e");
// 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, CountryName);
// 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 and capture" request
TransactionResponse response = PayUPayments.doAuthorizationAndCapture(parameters);
$parameters = array(
// Enter the account’s identifier here
PayUParameters::ACCOUNT_ID => $accountId,
// 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 => $currency,
// -- Buyer --
// Enter the buyer information here.
//PayUParameters::[...] => [...],
// -- Payer --
// Enter the payer information here.
//PayUParameters::[...] => [...],
// -- Credit card data --
// Enter the credit card token here
PayUParameters::TOKEN_ID => "ab01ecd5-7d8f-4bee-91c1-4535d9ba282e",
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 => $country,
// 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 and Capture" request
$response = PayUPayments::doAuthorizationAndCapture($parameters);
For specific details about how to perform payments, refer to the respective article according to the processing country.