IPP (Installment Payment Plan)

The 2C2P PGW SDK allows merchants to offer Installment Payment Plans (IPP) to their customers. Customers have the option of selecting Installment Payment Plans from multiple banks.

šŸ“˜

API Method

Refer to: PGW SDK API Interface

šŸš§

References

SDK Payment Classes
SDK Payment Enums

Ā 

1. Generate Payment Token

To prepare a payment token request, refer to the required parameters below.

šŸ“˜

Payment Token API

Refer to: Payment Token API

{
    "merchantID": "JT04",
    "invoiceNo": "1595219400",
    "description": "2 days 1 night hotel room",
    "amount": 10.0,
    "currencyCode": "THB",
    "nonceStr": "a8092512-b144-41b0-8284-568bb5e9264c",
    "paymentChannel": ["GCARD"],
    "request3DS": "Y",
    "installmentPeriodFilter": [6],
    "interestType": "M",
    "productCode": "ProductA",
    "promotionCode": "PromoA"
}

Ā 

2. Receive Payment Token Response

To receive a payment token response, refer to the sample payment token response below.

String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z1dJgGQ62S6CGwy2SP852ud2QXNFI20wDcZbWHCQtCqERaqGYyENDFpnchZrpiXkGVSc1eYtOwOFunPcyGTSLfP";
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z1dJgGQ62S6CGwy2SP852ud2QXNFI20wDcZbWHCQtCqERaqGYyENDFpnchZrpiXkGVSc1eYtOwOFunPcyGTSLfP";
let paymentToken:String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z1dJgGQ62S6CGwy2SP852ud2QXNFI20wDcZbWHCQtCqERaqGYyENDFpnchZrpiXkGVSc1eYtOwOFunPcyGTSLfP"

Ā 

3. Prepare Installment Payment Plan Request

To prepare an IPP (Installment Payment Plan) request, refer to the parameters and sample code below.

šŸ“˜

Payment Request Parameters

Refer to: Payment Request API Parameters

šŸš§

Payment Channels

To see all available IPP options, refer to the following section in the payment channel matrix:
ā€¢ Global Cards

PaymentCode paymentCode = new PaymentCode("IPP");
 
PaymentRequest paymentRequest = new CardPaymentBuilder(paymentCode, "4111111111111111")
                                .setExpiryMonth(12)
                                .setExpiryYear(2020)
                                .setSecurityCode("123")
                                .setInstallmentInterestType(InstallmentInterestTypeCode.Merchant)
                                .setInstallmentPeriod(6)
                                .build();
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"IPP"];
  
PaymentRequest *paymentRequest = [[[[[[[[CardPaymentBuilder alloc] initWithPaymentCode: paymentCode cardNo: @"4111111111111111"]
                                         expiryMonth: 12]
                                         expiryYear: 2020]
                                         securityCode: @"123"]
                                         installmentInterestType: InstallmentInterestTypeCode.Merchant]
                                         installmentPeriod: 6]
                                         build];
let paymentCode: PaymentCode = PaymentCode(channelCode: "IPP")
         
let paymentRequest: PaymentRequest = CardPaymentBuilder(paymentCode: paymentCode, "4111111111111111")
                                     .expiryMonth(12)
                                     .expiryYear(2020)
                                     .securityCode("123")
                                     .installmentInterestType(InstallmentInterestTypeCode.Merchant)
                                     .installmentPeriod(6)
                                     .build()

Ā 

4. Prepare Transaction Request

To prepare a transaction request, refer to the parameters below.

šŸ“˜

Transaction Request API Parameters

Refer to: Do Payment Request API Parameter

TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
                                                    .with(paymentRequest)
                                                    .build();
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                         withPaymentRequest: paymentRequest]
                                                         build];
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentRequest)
                                                         .build()

Ā 

5. Receive Transaction Request Response

To receive a transaction request response, refer to the parameters below.

šŸ“˜

Transaction Response API Parameters

Refer to: Do Payment Response API Parameters

šŸš§

References

Response Code
To view payment process flows based on response code, refer to: Payment Flow Response Codes

PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {
   
     @Override
     public void onResponse(TransactionResultResponse response) {
   
          if(response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateRedirect) || response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateFullRedirect)) {
   
                String redirectUrl = response.getData(); //Open WebView
          } else if(response.getResponseCode().equals(APIResponseCode.TransactionCompleted)) {
   
               //Inquiry payment result by using invoice no.
          } else {
   
               //Get error response and display error.
          }
     }
   
     @Override
     public void onFailure(Throwable error) {
   
          //Get error response and display error.
     }
});
[[PGWSDK shared] proceedTransactionWithTransactionResultRequest: transactionResultRequest response: ^(TransactionResultResponse * _Nonnull response) {
             
     if([response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateRedirect] || [response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateFullRedirect]) {
                 
          NSString *redirectUrl = response.data; //Open WebView
     } else if([response.responseCode isEqualToString: APIResponseCode.TransactionCompleted]) {
                 
          //Inquiry payment result by using invoice no.
     } else {
                 
          //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) {
             
     //Get error response and display error.
}];
PGWSDK.shared.proceedTransaction(transactionResultRequest: transactionResultRequest, { (response: TransactionResultResponse) in
     
     if response.responseCode == APIResponseCode.TransactionAuthenticateRedirect || response.responseCode == APIResponseCode.TransactionAuthenticateFullRedirect {
                  
           guard let redirectUrl: String = response.data else { return } //Open WebView
     } else if response.responseCode == APIResponseCode.TransactionCompleted {
                  
           //Inquiry payment result by using invoice no.
     } else {
                  
           //Get error response and display error.
     }
}) { (error: NSError) in
              
     //Get error response and display error.
}

šŸ‘

Callback for PGW Payment Authentication

Refer to: Handle PGW Payment Authentication

Ā 

6. Initiate Payment Inquiry

To retrieve payment details and card tokens, merchants must initiate the Payment Inquiry API. Refer to the sample code below.

šŸ“˜

Payment Inquiry API

Refer to: Payment Inquiry API

Ā 

Full Sample Code

The following sample code demonstrates requests and responses for each step of the process.

//Step 1: Generate payment token id.
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
   
//Step 2: Construct installment payment plan request.
PaymentCode paymentCode = new PaymentCode("IPP");
 
PaymentRequest paymentRequest = new CardPaymentBuilder(paymentCode, "4111111111111111")
                                .setExpiryMonth(12)
                                .setExpiryYear(2020)
                                .setSecurityCode("123")
                                .setInstallmentInterestType(InstallmentInterestTypeCode.Merchant)
                                .setInstallmentPeriod(6)
                                .build();
   
//Step 3: Construct transaction request.
TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
                                                    .with(paymentRequest)
                                                    .build();
   
//Step 4: Execute payment request.
PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {
   
     @Override
     public void onResponse(TransactionResultResponse response) {
   
          if(response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateRedirect) || response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateFullRedirect)) {
   
                String redirectUrl = response.getData(); //Open WebView
          } else if(response.getResponseCode().equals(APIResponseCode.TransactionCompleted)) {
   
               //Inquiry payment result by using invoice no.
          } else {
   
               //Get error response and display error.
          }
     }
   
     @Override
     public void onFailure(Throwable error) {
   
          //Get error response and display error.
     }
});
//Step 1: Generate payment token id.
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
  
//Step 2: Construct installment payment plan request.
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"IPP"];
  
PaymentRequest *paymentRequest = [[[[[[[[CardPaymentBuilder alloc] initWithPaymentCode: paymentCode cardNo: @"4111111111111111"]
                                         expiryMonth: 12]
                                         expiryYear: 2020]
                                         securityCode: @"123"]
                                         installmentInterestType: InstallmentInterestTypeCode.Merchant]
                                         installmentPeriod: 6]
                                         build];
  
//Step 3: Construct transaction request.  
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                         withPaymentRequest: paymentRequest]
                                                         build];
      
//Step 4: Execute payment request.
[[PGWSDK shared] proceedTransactionWithTransactionResultRequest: transactionResultRequest response: ^(TransactionResultResponse * _Nonnull response) {
             
     if([response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateRedirect] || [response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateFullRedirect]) {
                 
          NSString *redirectUrl = response.data; //Open WebView
     } else if([response.responseCode isEqualToString: APIResponseCode.TransactionCompleted]) {
                 
          //Inquiry payment result by using invoice no.
     } else {
                 
          //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) {
             
     //Get error response and display error.
}];
//Step 1: Generate payment token id.
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
     
//Step 2: Construct installment payment plan request.
let paymentCode: PaymentCode = PaymentCode(channelCode: "IPP")
         
let paymentRequest: PaymentRequest = CardPaymentBuilder(paymentCode: paymentCode, "4111111111111111")
                                     .expiryMonth(12)
                                     .expiryYear(2020)
                                     .securityCode("123")
                                     .installmentInterestType(InstallmentInterestTypeCode.Merchant)
                                     .installmentPeriod(6)
                                     .build()
 
//Step 3: Construct transaction request.
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentRequest)
                                                         .build()
          
//Step 4: Execute payment request.
PGWSDK.shared.proceedTransaction(transactionResultRequest: transactionResultRequest, { (response: TransactionResultResponse) in
     
     if response.responseCode == APIResponseCode.TransactionAuthenticateRedirect || response.responseCode == APIResponseCode.TransactionAuthenticateFullRedirect {
                  
           guard let redirectUrl: String = response.data else { return } //Open WebView
     } else if response.responseCode == APIResponseCode.TransactionCompleted {
                  
           //Inquiry payment result by using invoice no.
     } else {
                  
           //Get error response and display error.
     }
}) { (error: NSError) in
              
     //Get error response and display error.
}