Card tokenization
'Card Tokenization' Securely save your customers' credit card information in 2C2P PGW Vault.
Here are 7 steps to make a successful card tokenization payment:
- Step 1: Get payment token.
- Step 2: Enable Tokenization.
- Step 3: Construct credit card request.
- Step 4: Construct transaction request.
- Step 5: Execute payment request.
- Step 6:Get payment result.
- Step 7:Get card token.
Payment Token API
Please refer: Full sample code
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
let paymentToken:String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
Set payment option
boolean storeCard = true; //Enable or Disable Tokenization
let storeCard:Bool = true //Enable or Disable Tokenization
BOOL storeCard = true; //Enable or Disable Tokenization
Step 3: Construct credit card request.
CreditCardPayment creditCardPayment = new CreditCardPaymentBuilder("4111111111111111")
.setExpiryMonth(12)
.setExpiryYear(2019)
.setSecurityCode("123")
.setStoreCard(storeCard)
.build();
let creditCardPayment:CreditCardPayment = CreditCardPaymentBuilder(pan: "4111111111111111")
.expiryMonth(12)
.expiryYear(2019)
.securityCode("123")
.storeCard(storeCard)
.build()
CreditCardPayment *creditCardPayment = [[[[[[[CreditCardPaymentBuilder alloc]
initWithPan:@"4111111111111111"]
expiryMonth:12]
expiryYear:2019]
securityCode:@"123"]
storeCard:storeCard]
build];
To do so the following fields need to be populated:
Variable | Description |
---|---|
storeCard | Selection to store cardholder data at 2C2P. (Conditional) |
Step 4: Construct transaction request.
TransactionRequest transactionRequest = new TransactionRequestBuilder(paymentToken)
.withCreditCardPayment(creditCardPayment)
.build();
let transactionRequest:TransactionRequest = TransactionRequestBuilder(paymentToken: paymentToken)
.withCreditCardPayment(creditCardPayment)
.build()
TransactionRequest *transactionRequest = [[[[TransactionRequestBuilder alloc]
initWithPaymentToken:paymentToken]
withCreditCardPayment:creditCardPayment]
build];
Step 5: Execute payment request.
PGWSDK.getInstance().proceedTransaction(transactionRequest, new TransactionResultCallback() {
@Override
public void onResponse(TransactionResultResponse response) {
if(response.getResponseCode().equals(APIResponseCode.TRANSACTION_COMPLETED)) {
//Inquiry payment result by using transaction id.
String transactionID = response.getTransactionID();
} else {
//Get error response and display error
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error
}
});
PGWSDK.shared.proceedTransaction(transactionRequest: transactionRequest,
success: { (response:TransactionResultResponse) in
if response.responseCode == APIResponseCode.TRANSACTION_COMPLETED {
//Inquiry payment result by using transaction id.
let transactionID:String = response.transactionID!
} else {
//Get error response and display error
}
}) { (error:NSError) in
//Get error response and display error
}
[[PGWSDK shared] proceedTransactionWithTransactionRequest:transactionRequest
success:^(TransactionResultResponse * _Nonnull response) {
if ([response.responseCode isEqualToString:APIResponseCode.TRANSACTION_COMPLETED]) {
//Inquiry payment result by using transaction id.
NSString *transactionID = response.transactionID;
} else {
//Get error response and display error
}
} failure:^(NSError * _Nonnull error) {
//Get error response and display error
}];
Payment Inquiry API
Please refer: Full sample code
$payment_inquiry_response = $pgw_helper->parseAPIResponse($encoded_payment_inquiry_response);
$card_token = $payment_inquiry_response->cardToken;
Note: In order for a token to be generated the initial payment request needs to be authorized successfully.
Complete Code
Copy & Paste below source code into your application.
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
boolean storeCard = true; //Enable or Disable Tokenization
//Construct credit card request
CreditCardPayment creditCardPayment = new CreditCardPaymentBuilder("4111111111111111")
.setExpiryMonth(12)
.setExpiryYear(2019)
.setSecurityCode("123")
.setStoreCard(storeCard)
.build();
//Construct transaction request
TransactionRequest transactionRequest = new TransactionRequestBuilder(paymentToken)
.withCreditCardPayment(creditCardPayment)
.build();
//Execute payment request
PGWSDK.getInstance().proceedTransaction(transactionRequest, new TransactionResultCallback() {
@Override
public void onResponse(TransactionResultResponse response) {
if(response.getResponseCode().equals(APIResponseCode.TRANSACTION_COMPLETED)) {
//Inquiry payment result by using transaction id.
String transactionID = response.getTransactionID();
} else {
//Get error response and display error
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error
}
});
let paymentToken:String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
let storeCard:Bool = true //Enable or Disable Tokenization
//Construct credit card request
let creditCardPayment:CreditCardPayment = CreditCardPaymentBuilder(pan: "4111111111111111")
.expiryMonth(12)
.expiryYear(2019)
.securityCode("123")
.storeCard(storeCard)
.build()
//Construct transaction request
let transactionRequest:TransactionRequest = TransactionRequestBuilder(paymentToken: paymentToken)
.withCreditCardPayment(creditCardPayment)
.build()
//Execute payment request
PGWSDK.shared.proceedTransaction(transactionRequest: transactionRequest,
success: { (response:TransactionResultResponse) in
if response.responseCode == APIResponseCode.TRANSACTION_COMPLETED {
//Inquiry payment result by using transaction id.
let transactionID:String = response.transactionID!
} else {
//Get error response and display error
}
}) { (error:NSError) in
//Get error response and display error
}
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
BOOL storeCard = true; //Enable or Disable Tokenization
//Construct credit card request
CreditCardPayment *creditCardPayment = [[[[[[[CreditCardPaymentBuilder alloc]
initWithPan:@"4111111111111111"]
expiryMonth:12]
expiryYear:2019]
securityCode:@"123"]
storeCard:storeCard]
build];
//Construct transaction request
TransactionRequest *transactionRequest = [[[[TransactionRequestBuilder alloc]
initWithPaymentToken:paymentToken]
withCreditCardPayment:creditCardPayment]
build];
//Execute payment request
[[PGWSDK shared] proceedTransactionWithTransactionRequest:transactionRequest
success:^(TransactionResultResponse * _Nonnull response) {
if ([response.responseCode isEqualToString:APIResponseCode.TRANSACTION_COMPLETED]) {
//Inquiry payment result by using transaction id.
NSString *transactionID = response.transactionID;
} else {
//Get error response and display error
}
} failure:^(NSError * _Nonnull error) {
//Get error response and display error
}];
Updated 16 days ago