Payment Option

The Payment Options API allows merchants to retrieve details for their merchant account configuration, enabled payment options, and transactions.

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 Option Request

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

πŸ“˜

Request API Parameters

Refer to: Payment Option Request API Parameters

PaymentOptionRequest paymentOptionRequest = new PaymentOptionRequest(paymentToken);
PaymentOptionRequest *paymentOptionRequest = [[PaymentOptionRequest alloc] initWithPaymentToken: paymentToken];
let paymentOptionRequest: PaymentOptionRequest = PaymentOptionRequest(paymentToken: paymentToken)

Β 

4. Receive Payment Option Response

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

πŸ“˜

Response API Parameters

Refer to: Payment Option Response API Parameters

PGWSDK.getInstance().paymentOption(paymentOptionRequest, new APIResponseCallback<PaymentOptionResponse>() {
     @Override
     public void onResponse(PaymentOptionResponse response) {
         if(response.getResponseCode().equals(APIResponseCode.APISuccess)) {
             //Read payment option response. 
         } else {
             //Get error response and display error.
         }
     }
 
     @Override
     public void onFailure(Throwable error) {
         //Get error response and display error.
     }
});
[[PGWSDK shared] paymentOptionWithPaymentOptionRequest: paymentOptionRequest response: ^(PaymentOptionResponse * _Nonnull response) {
         
     if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
 
          //Read payment option response.
     } else {
 
         //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) { 
 
     //Get error response and display error.
}];
PGWSDK.shared.paymentOption(paymentOptionRequest: paymentOptionRequest, { (response: PaymentOptionResponse) in
 
     if response.responseCode == APIResponseCode.APISuccess {
 
          //Read payment option response.
     } 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.

//Step 1 : Generate payment token
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
 
//Step 2: Construct payment option request.
PaymentOptionRequest paymentOptionRequest = new PaymentOptionRequest(paymentToken);
 
//Step 3: Retrieve payment options response.
PGWSDK.getInstance().paymentOption(paymentOptionRequest, new APIResponseCallback<PaymentOptionResponse>() {
     @Override
     public void onResponse(PaymentOptionResponse response) { 
         if(response.getResponseCode().equals(APIResponseCode.APISuccess)) {
             //Read payment option 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 option request.
PaymentOptionRequest *paymentOptionRequest = [[PaymentOptionRequest alloc] initWithPaymentToken: paymentToken];
     
//Step 3: Retrieve payment options response.
[[PGWSDK shared] paymentOptionWithPaymentOptionRequest: paymentOptionRequest response: ^(PaymentOptionResponse * _Nonnull response) {
         
     if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
 
          //Read payment option 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 option request.
let paymentOptionRequest: PaymentOptionRequest = PaymentOptionRequest(paymentToken: paymentToken)
 
//Step 3: Retrieve payment options response.
PGWSDK.shared.paymentOption(paymentOptionRequest: paymentOptionRequest, { (response: PaymentOptionResponse) in
 
     if response.responseCode == APIResponseCode.APISuccess {
 
          //Read payment option response.
     } else {
 
          //Get error response and display error.
     }
}) { (error: NSError) in
 
     //Get error response and display error.
}