Deep Link Payment

2C2P allows merchants to make payment with secured and seamlessly with third party mobile APP.

šŸ“˜

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.

šŸ“˜

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": ["DEEPLINK"]
}

2. Receive Payment Token Response

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

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"

3. Construct Deep Link Payment Request

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

šŸ“˜

Payment Request Parameter

Refer to: Payment Request API Parameter

šŸš§

Payment Channels

To see individual card tokenization options, refer to the following sections in the payment channel matrix:
ā€¢ Deeplink

PaymentCode paymentCode = new PaymentCode("123", "THSCB", "DEEPLINK");
 
PaymentRequest paymentRequest = new DeepLinkPaymentBuilder(paymentCode)
                                .setName("DavidBilly")
                                .setEmail("[email protected]")
                                .setMobileNo("08888888")
                                .build();
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"123" agentCode: @"THSCB" agentChannelCode: @"DEEPLINK"];
          
PaymentRequest *paymentRequest = [[[[[[DeepLinkPaymentBuilder alloc] initWithPaymentCode: paymentCode]
                                       name: @"DavidBilly"]
                                       email: @"[email protected]"]
                                       mobileNo: @"08888888"]
                                       build];
let paymentCode: PaymentCode = PaymentCode(channelCode: "123", "THSCB", "DEEPLINK")
 
let paymentRequest: PaymentRequest = DeepLinkPaymentBuilder(paymentCode: paymentCode)
                                     .name("DavidBilly")
                                     .email("[email protected]")
                                     .mobileNo("08888888")
                                     .build()

4. Construct Transaction Request

To prepare a payment 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(paymentRequest)
                                                    .build();
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                         withPaymentRequest: paymentRequest]
                                                         build];)
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentRequest)
                                                         .build()

5. Execute Payment Request

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

šŸ“˜

Payment 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.TransactionExternalApplication)) {
 
               String appDeepLink = response.getData(); //Open external application          
           } 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.TransactionExternalApplication]) {
             
         NSString *appDeepLink = response.data; //Open external application      
     } 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 {
             
          let redirectUrl: String = response.data //Open WebView
     } else if response.responseCode == APIResponseCode.TransactionExternalApplication {
                 
          let appDeepLink: String = response.data //Open external application     
     } 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

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 Deep Link payment request.
PaymentCode paymentCode = new PaymentCode("123", "THSCB", "DEEPLINK");
 
PaymentRequest paymentRequest = new DeepLinkPaymentBuilder(paymentCode)
                                .setName("DavidBilly")
                                .setEmail("[email protected]")
                                .setMobileNo("08888888")
                                .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.TransactionExternalApplication)) {
 
               String appDeepLink = response.getData(); //Open external application          
           } 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 Deep Link payment request.
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"123" agentCode: @"THSCB" agentChannelCode: @"DEEPLINK"];
          
PaymentRequest *paymentRequest = [[[[[[DeepLinkPaymentBuilder alloc] initWithPaymentCode: paymentCode]
                                       name: @"DavidBilly"]
                                       email: @"[email protected]"]
                                       mobileNo: @"08888888"]
                                       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.TransactionExternalApplication]) {
             
         NSString *appDeepLink = response.data; //Open external application      
     } 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 Deep Link payment request.
let paymentCode: PaymentCode = PaymentCode(channelCode: "123", "THSCB", "DEEPLINK")
 
let paymentRequest: PaymentRequest = DeepLinkPaymentBuilder(paymentCode: paymentCode)
                                     .name("DavidBilly")
                                     .email("[email protected]")
                                     .mobileNo("08888888")
                                     .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 {
             
          let redirectUrl: String = response.data //Open WebView
     } else if response.responseCode == APIResponseCode.TransactionExternalApplication {
                 
          let appDeepLink: String = response.data //Open external application     
     } else {
                 
          //Get error response and display error.
     }
}) { (error: NSError) in
             
     //Get error response and display error.
}