Payment Notification

The Payment Notification API is for send payment result notification to customer preference media platform, such as Facebook, WhatApps, WeChat, Email and etc-etc.

Below are steps to retrieve payment options.

Step 1 : Generate Payment Token

Step 2 : Construct Payment Notification Request

Step 3 : Retrieve Payment Notification Response

Full Sample Code

Β 

πŸ“˜

API Method

PGW SDK API Interface

🚧

References

SDK Payment Classes
SDK Payment Enums

Β 

Step 1 :Generate Payment Token

Β 
1.1 Generate payment token ID.

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

Β 
1.2 Get payment token ID from response and pass it to merchant mobile 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

Please refer: Payment Token API

Β 

Step 2 : Construct Payment Notification Request

Below code show how to construct payment notification request.

πŸ“˜

Request API Parameter

Please refer: Payment Notification Request API Parameter

PaymentNotificationRequest paymentNotificationRequest = new PaymentNotificationRequest(paymentToken);
paymentNotificationRequest.setPlatform(PaymentNotificationPlatformCode.Email);
paymentNotificationRequest.setRecipientId("[email protected]");
paymentNotificationRequest.setRecipientName("DavidBilly");
PaymentNotificationRequest *paymentNotificationRequest = [[PaymentNotificationRequest alloc] initWithPaymentToken: paymentToken];
paymentNotificationRequest.platform = PaymentNotificationPlatformCode.Email;
paymentNotificationRequest.recipientName = @"DavidBilly";
paymentNotificationRequest.recipientId = @"[email protected]";
let paymentNotificationRequest: PaymentNotificationRequest = PaymentNotificationRequest(paymentToken: paymentToken)
paymentNotificationRequest.platform = PaymentNotificationPlatformCode.Email
paymentNotificationRequest.recipientName = "DavidBilly"
paymentNotificationRequest.recipientId = "[email protected]"

Β 

Step 3 : Retrieve Payment Notification Response

Below code show how to retrieve payment notification response.

πŸ“˜

Response API Parameter

Please refer: Payment Notification Response API Parameter

PGWSDK.getInstance().paymentNotification(paymentNotificationRequest, new APIResponseCallback<PaymentNotificationResponse>() {
 
     @Override
     public void onResponse(PaymentNotificationResponse response) {
         if(response.getResponseCode().equals(APIResponseCode.APISuccess)) {
             //Read payment notification response. 
         } else {
             //Get error response and display error.
         }
     }
 
     @Override
     public void onFailure(Throwable error) {
         //Get error response and display error.
     }
});
[[PGWSDK shared] paymentNotificationWithPaymentNotificationRequest: paymentNotificationRequest response: ^(PaymentNotificationResponse * _Nonnull response) {        
     if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
          //Read payment notification response.
     } else {
         //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) { 
     //Get error response and display error.
}];
PGWSDK.shared.paymentNotification(paymentNotificationRequest: paymentNotificationRequest, { (response: PaymentNotificationResponse) in
     if response.responseCode == APIResponseCode.APISuccess {
          //Read payment notification response.
     } else { 
          //Get error response and display error.
     }
}) { (error: NSError) in
     //Get error response and display error.
}

Β 

Full Sample Code

Full Sample Code Show below.

//Step 1 : Generate payment token
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
 
//Step 2: Construct payment notification request.
PaymentNotificationRequest paymentNotificationRequest = new PaymentNotificationRequest(paymentToken);
paymentNotificationRequest.setPlatform(PaymentNotificationPlatformCode.Email);
paymentNotificationRequest.setRecipientId("[email protected]");
paymentNotificationRequest.setRecipientName("DavidBilly");
 
//Step 3: Retrieve payment notification response.
PGWSDK.getInstance().paymentNotification(paymentNotificationRequest, new APIResponseCallback<PaymentNotificationResponse>() {
 
     @Override
     public void onResponse(PaymentNotificationResponse response) {
         if(response.getResponseCode().equals(APIResponseCode.APISuccess)) {
             //Read payment notification response. 
         } else {
             //Get error response and display error.
         }
     }
 
     @Override
     public void onFailure(Throwable error) {
         //Get error response and display error.
     }
});
//Step 1 : Generate payment token
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
 
//Step 2: Construct payment notification request.
PaymentNotificationRequest *paymentNotificationRequest = [[PaymentNotificationRequest alloc] initWithPaymentToken: paymentToken];
paymentNotificationRequest.platform = PaymentNotificationPlatformCode.Email;
paymentNotificationRequest.recipientName = @"DavidBilly";
paymentNotificationRequest.recipientId = @"[email protected]";
     
//Step 3: Retrieve payment notification response.
[[PGWSDK shared] paymentNotificationWithPaymentNotificationRequest: paymentNotificationRequest response: ^(PaymentNotificationResponse * _Nonnull response) {     
     if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
          //Read payment notification response.
     } else {
         //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) { 
     //Get error response and display error.
}];
//Step 1 : Generate payment token
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
 
//Step 2: Construct payment notification request.
let paymentNotificationRequest: PaymentNotificationRequest = PaymentNotificationRequest(paymentToken: paymentToken)
paymentNotificationRequest.platform = PaymentNotificationPlatformCode.Email
paymentNotificationRequest.recipientName = "DavidBilly"
paymentNotificationRequest.recipientId = "[email protected]"
         
//Step 3: Retrieve payment notification response.
PGWSDK.shared.paymentNotification(paymentNotificationRequest: paymentNotificationRequest, { (response: PaymentNotificationResponse) in
 
     if response.responseCode == APIResponseCode.APISuccess {
          //Read payment notification response.
     } else {
          //Get error response and display error.
     }
}) { (error: NSError) in
     //Get error response and display error.
}