Payment UI

The Payment UI feature allows merchant provide payment UI to user with little to no effort by using 2C2P's PGW payment UI.

Refer to the links below for parameters and code samples for each step:

Β 

πŸ“˜

API Method

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.

{
    "merchantID": "JT04",
    "invoiceNo": "1595219400",
    "description": "2 days 1 night hotel room",
    "amount": 10.0,
    "currencyCode": "THB",
    "nonceStr": "a8092512-b144-41b0-8284-568bb5e9264c",
    "paymentChannel": ["ALL"]
}

Β 

2. Receive Payment Token Response

To receive a payment token response, refer to the sample payment token response below. The response will contain the payment token ID which must be passed to the merchant application.

String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"

πŸ“˜

Payment Token API

Refer to: Payment Token API

Β 

3. Prepare Payment UI Request

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

πŸ“˜

Payment UI Request Parameters

Refer to: Payment UI Request API Parameters

PaymentUIRequest paymentUIRequest = new PaymentUIBuilder(activity).build();
PaymentUIRequest *paymentUIRequest = [[[PaymentUIBuilder alloc] initWithUiViewController: uiViewController] build];
let paymentUIRequest: PaymentUIRequest = PaymentUIBuilder(uiViewController: uiViewController).build()

Β 

4. Prepare Transaction Request

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

πŸ“˜

Payment Transaction Request API Parameters

Refer to: Do Payment Request API Parameters

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

Β 

5. Execute Payment UI Request

To execute a payment request and receive the API response, refer to the parameters below.

πŸ“˜

Payment Transaction Response API Parameters

Refer to: Do Payment Response API Parameters

PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {

    @Override
    public void onResponse(TransactionResultResponse response) {

         if(response.getResponseCode().equals(PaymentUIResponseCode.TransactionCompleted)) {
                    
              //Inquiry transaction status inquiry by using payment token.
              String paymentToken = response.getPaymentToken();
         } 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: PaymentUIResponseCode.TransactionCompleted]) {
             
          //Inquiry transaction status inquiry by using payment token.
          NSString *paymentToken = response.paymentToken;
     } 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 == PaymentUIResponseCode.TransactionCompleted {
                
           //Inquiry transaction status inquiry by using payment token.
           let paymentToken: String = response.paymentToken
     } else {

           //Get error response and display error
     }
}) { (error: NSError) in

     //Get error response and display error
}

Β 

Full Sample Code

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

String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
 
//Step 2: Construct payment ui request.
PaymentUIRequest paymentUIRequest = new PaymentUIBuilder(activity).build();
 
//Step 3: Construct transaction request.
TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
                                                    .with(paymentUIRequest)
                                                    .build();
 
//Step 4: Execute payment ui request.
PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {

    @Override
    public void onResponse(TransactionResultResponse response) {

         if(response.getResponseCode().equals(PaymentUIResponseCode.TransactionCompleted)) {
                    
              //Inquiry transaction status inquiry by using payment token.
              String paymentToken = response.getPaymentToken();
         } else {

              //Get error response and display error
         }
    }

    @Override
    public void onFailure(Throwable error) {
                
         //Get error response and display error
    }
});
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
 
//Step 2: Construct payment ui request.
PaymentUIRequest *paymentUIRequest = [[[PaymentUIBuilder alloc] initWithUiViewController: uiViewController] build];
 
//Step 3: Construct transaction request.   
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                           withPaymentUIRequest: paymentUIRequest]
                                                           build];
     
//Step 4: Execute payment ui request.
[[PGWSDK shared] proceedTransactionWithTransactionResultRequest: transactionResultRequest response: ^(TransactionResultResponse * _Nonnull response) {
                
     if([response.responseCode isEqualToString: PaymentUIResponseCode.TransactionCompleted]) {
             
          //Inquiry transaction status inquiry by using payment token.
          NSString *paymentToken = response.paymentToken;
     } else {
             
          //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) {
        
     //Get error response and display error.
}];
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
    
//Step 2: Construct payment ui request.
let paymentUIRequest: PaymentUIRequest = PaymentUIBuilder(uiViewController: uiViewController).build()
         
//Step 3: Construct transaction request.
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentUIRequest)
                                                         .build()
         
//Step 4: Execute payment ui request.
PGWSDK.shared.proceedTransaction(transactionResultRequest: transactionResultRequest, { (response: TransactionResultResponse) in

     if response.responseCode == PaymentUIResponseCode.TransactionCompleted {
                
           //Inquiry transaction status inquiry by using payment token.
           let paymentToken: String = response.paymentToken
     } else {

           //Get error response and display error
     }
}) { (error: NSError) in

     //Get error response and display error
}