Payment Option Details
The Payment Option Details API allows merchants to retrieve payment information based on their merchant account configuration.
API Method
References
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": ["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";
val 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"
String paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
let paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
3. Prepare Payment Option Detail Request
To prepare a payment option detail request, refer to the parameters below.
Request API Parameters
PaymentOptionDetailRequest paymentOptionDetailRequest = new PaymentOptionDetailRequest(paymentToken);
paymentOptionDetailRequest.setCategoryCode(PaymentChannelCode.Category.GlobalCardPayment);
paymentOptionDetailRequest.setGroupCode(PaymentChannelCode.Group.GlobalInstallmentPaymentPlan);
val paymentOptionDetailRequest = PaymentOptionDetailRequest(paymentToken).apply {
categoryCode = PaymentChannelCode.Category.GlobalCardPayment
groupCode = PaymentChannelCode.Group.GlobalInstallmentPaymentPlan
}
PaymentOptionDetailRequest *paymentOptionDetailRequest = [[PaymentOptionDetailRequest alloc] initWithPaymentToken: paymentToken];
paymentOptionDetailRequest.categoryCode = PaymentChannelCodeCategory.GlobalCardPayment;
paymentOptionDetailRequest.groupCode = PaymentChannelCodeGroup.CreditCard;
let paymentOptionDetailRequest: PaymentOptionDetailRequest = PaymentOptionDetailRequest(paymentToken: paymentToken)
paymentOptionDetailRequest.categoryCode = PaymentChannelCode.Category.GlobalCardPayment
paymentOptionDetailRequest.groupCode = PaymentChannelCode.Group.CreditCard
Map<String, dynamic> paymentOptionDetailRequest = {
'paymentToken': paymentToken,
'categoryCode': PaymentChannelCode.category.globalCardPayment,
'groupCode': PaymentChannelCode.group.creditCard
};
let paymentOptionDetailRequest = {
'paymentToken': paymentToken,
'categoryCode': PaymentChannelCode.category.globalCardPayment,
'groupCode': PaymentChannelCode.group.creditCard
};
4. Receive Payment Option Detail Response
To receive a payment option detail response, refer to the parameters below.
Response API Parameters
PGWSDK.getInstance().paymentOptionDetail(paymentOptionDetailRequest, new APIResponseCallback<PaymentOptionDetailResponse>() {
@Override
public void onResponse(PaymentOptionDetailResponse response) {
if (response.getResponseCode().equals(APIResponseCode.APISuccess)) {
//Read Payment option details response.
} else {
//Get error response and display error.
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error.
}
});
PGWSDK.getInstance().paymentOptionDetail(paymentOptionDetailRequest, object : APIResponseCallback<PaymentOptionDetailResponse> {
override fun onResponse(response: PaymentOptionDetailResponse) {
if (response.responseCode == APIResponseCode.APISuccess) {
//Read Payment option details response.
} else {
//Get error response and display error.
}
}
override fun onFailure(error: Throwable) {
//Get error response and display error.
}
})
[[PGWSDK shared] paymentOptionDetailWithPaymentOptionDetailRequest: paymentOptionDetailRequest response: ^(PaymentOptionDetailResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
//Read Payment option details response.
} else {
//Get error response and display error.
}
} failure: ^(NSError * _Nonnull error) {
//Get error response and display error.
}];
PGWSDK.shared.paymentOptionDetail(paymentOptionDetailRequest: paymentOptionDetailRequest, { (response: PaymentOptionDetailResponse) in
if response.responseCode == APIResponseCode.APISuccess {
//Read Payment option details response.
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}
PGWSDK().paymentOptionDetail(paymentOptionDetailRequest, (response) {
if (response['responseCode'] == APIResponseCode.apiSuccess) {
//Read Payment option details response.
} else {
//Get error response and display error.
}
}, (error) {
//Get error response and display error.
});
await RTNPGW.paymentOptionDetail(JSON.stringify(paymentOptionDetailRequest)).then((response: string) => {
let paymentOptionDetailResponse = JSON.parse(response);
if (paymentOptionDetailResponse?.responseCode == APIResponseCode.apiSuccess) {
//Read Payment option details response.
} else {
//Get error response and display error
}
}).catch ((error: Error) => {
//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 details request.
PaymentOptionDetailRequest paymentOptionDetailRequest = new PaymentOptionDetailRequest(paymentToken);
paymentOptionDetailRequest.setCategoryCode(PaymentChannelCode.Category.GlobalCardPayment);
paymentOptionDetailRequest.setGroupCode(PaymentChannelCode.Group.GlobalInstallmentPaymentPlan);
//Step 3: Retrieve payment option details response.
PGWSDK.getInstance().paymentOptionDetail(paymentOptionDetailRequest, new APIResponseCallback<PaymentOptionDetailResponse>() {
@Override
public void onResponse(PaymentOptionDetailResponse response) {
if (response.getResponseCode().equals(APIResponseCode.APISuccess)) {
//Read Payment option details 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.
val paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
//Step 2: Construct payment option details request.
val paymentOptionDetailRequest = PaymentOptionDetailRequest(paymentToken).apply {
categoryCode = PaymentChannelCode.Category.GlobalCardPayment
groupCode = PaymentChannelCode.Group.GlobalInstallmentPaymentPlan
}
//Step 3: Retrieve payment option details response.
PGWSDK.getInstance().paymentOptionDetail(paymentOptionDetailRequest, object : APIResponseCallback<PaymentOptionDetailResponse> {
override fun onResponse(response: PaymentOptionDetailResponse) {
if (response.responseCode == APIResponseCode.APISuccess) {
//Read Payment option details response.
} else {
//Get error response and display error.
}
}
override fun onFailure(error: Throwable) {
//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 details request.
PaymentOptionDetailRequest *paymentOptionDetailRequest = [[PaymentOptionDetailRequest alloc] initWithPaymentToken: paymentToken];
paymentOptionDetailRequest.categoryCode = PaymentChannelCodeCategory.GlobalCardPayment;
paymentOptionDetailRequest.groupCode = PaymentChannelCodeGroup.CreditCard;
//Step 3: Retrieve payment option details response.
[[PGWSDK shared] paymentOptionDetailWithPaymentOptionDetailRequest: paymentOptionDetailRequest response: ^(PaymentOptionDetailResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
//Read Payment option details 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 details request.
let paymentOptionDetailRequest: PaymentOptionDetailRequest = PaymentOptionDetailRequest(paymentToken: paymentToken)
paymentOptionDetailRequest.categoryCode = PaymentChannelCode.Category.GlobalCardPayment
paymentOptionDetailRequest.groupCode = PaymentChannelCode.Group.CreditCard
//Step 3: Retrieve payment option details response.
PGWSDK.shared.paymentOptionDetail(paymentOptionDetailRequest: paymentOptionDetailRequest, { (response: PaymentOptionDetailResponse) in
if response.responseCode == APIResponseCode.APISuccess {
//Read Payment option details response.
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}
//Step 1: Generate payment token.
String paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
//Step 2: Construct payment option details request.
Map<String, dynamic> paymentOptionDetailRequest = {
'paymentToken': paymentToken,
'categoryCode': PaymentChannelCode.category.globalCardPayment,
'groupCode': PaymentChannelCode.group.creditCard
};
//Step 3: Retrieve payment option details response.
PGWSDK().paymentOptionDetail(paymentOptionDetailRequest, (response) {
if (response['responseCode'] == APIResponseCode.apiSuccess) {
//Read Payment option details response.
} else {
//Get error response and display error.
}
}, (error) {
//Get error response and display error.
});
//Step 1: Generate payment token.
let paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
//Step 2: Construct payment option details request.
let paymentOptionDetailRequest = {
'paymentToken': paymentToken,
'categoryCode': PaymentChannelCode.category.globalCardPayment,
'groupCode': PaymentChannelCode.group.creditCard
};
//Step 3: Retrieve payment option details response.
await RTNPGW.paymentOptionDetail(JSON.stringify(paymentOptionDetailRequest)).then((response: string) => {
let paymentOptionDetailResponse = JSON.parse(response);
if (paymentOptionDetailResponse?.responseCode == APIResponseCode.apiSuccess) {
//Read Payment option details response.
} else {
//Get error response and display error
}
}).catch ((error: Error) => {
//Get error response and display error
});
Updated 25 days ago