Transaction Status Inquiry
The Transaction Status API allows merchants to display payment result information to the customer.
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 Transaction Status Request
To prepare a transaction status request, refer to the parameters below.
Request API Parameters
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest(paymentToken);
transactionStatusRequest.setAdditionalInfo(true);
val transactionStatusRequest = TransactionStatusRequest(paymentToken).apply {
additionalInfo = true
}
TransactionStatusRequest *transactionStatusRequest = [[TransactionStatusRequest alloc] initWithPaymentToken: paymentToken];
transactionStatusRequest.additionalInfo = true;
let transactionStatusRequest: TransactionStatusRequest = TransactionStatusRequest(paymentToken: paymentToken)
transactionStatusRequest.additionalInfo = true
Map<String, dynamic> transactionStatusRequest = {
'paymentToken': paymentToken,
'additionalInfo': true
};
let transactionStatusRequest = {
'paymentToken': paymentToken,
'additionalInfo': true
};
4. Retrieve Transaction Status Response
To retrieve a transaction status response, refer to the parameters below.
Response API Parameters
PGWSDK.getInstance().transactionStatus(transactionStatusRequest, new APIResponseCallback<TransactionStatusResponse>() {
@Override
public void onResponse(TransactionStatusResponse response) {
if (response.getResponseCode().equals(APIResponseCode.TransactionNotFound) || response.getResponseCode().equals(APIResponseCode.TransactionCompleted)) {
//Read transaction status inquiry response.
} else {
//Get error response and display error.
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error.
}
});
PGWSDK.getInstance().transactionStatus(transactionStatusRequest, object : APIResponseCallback<TransactionStatusResponse> {
override fun onResponse(response: TransactionStatusResponse) {
if (response.responseCode == APIResponseCode.TransactionNotFound || response.responseCode == APIResponseCode.TransactionCompleted) {
//Read transaction status inquiry response.
} else {
//Get error response and display error.
}
}
override fun onFailure(error: Throwable) {
//Get error response and display error.
}
})
[[PGWSDK shared] transactionStatusWithTransactionStatusRequest: transactionStatusRequest response: ^(TransactionStatusResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.TransactionNotFound] || [response.responseCode isEqualToString: APIResponseCode.TransactionCompleted]) {
//Read transaction status inquiry response.
} else {
//Get error response and display error.
}
} failure: ^(NSError * _Nonnull error) {
//Get error response and display error.
}];
PGWSDK.shared.transactionStatus(transactionStatusRequest: transactionStatusRequest, { (response: TransactionStatusResponse) in
if response.responseCode == APIResponseCode.TransactionNotFound || response.responseCode == APIResponseCode.TransactionCompleted {
//Read transaction status inquiry response.
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}
PGWSDK().transactionStatus(transactionStatusRequest, (response) {
if (response['responseCode'] == APIResponseCode.transactionNotFound || response['responseCode'] == APIResponseCode.transactionCompleted) {
//Read transaction status inquiry response.
} else {
//Get error response and display error.
}
}, (error) {
//Get error response and display error.
});
await RTNPGW.transactionStatus(JSON.stringify(transactionStatusRequest)).then((response: string) => {
let transactionStatusResponse = JSON.parse(response);
if (transactionStatusResponse?.responseCode == APIResponseCode.transactionCompleted) {
//Read transaction status inquiry response.
} else {
//Get error response and display error
}
}).catch ((error: Error) => {
//Get error response and display error
});
5. Initiate Payment Inquiry
To retrieve full transaction details and status, merchants must initiate the Payment Inquiry API. Refer to the sample code below.
Payment Inquiry API
Refer to: Payment Inquiry API
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 transaction status inquiry request.
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest(paymentToken);
transactionStatusRequest.setAdditionalInfo(true);
//Step 3: Retrieve transaction status inquiry response.
PGWSDK.getInstance().transactionStatus(transactionStatusRequest, new APIResponseCallback<TransactionStatusResponse>() {
@Override
public void onResponse(TransactionStatusResponse response) {
if (response.getResponseCode().equals(APIResponseCode.TransactionNotFound) || response.getResponseCode().equals(APIResponseCode.TransactionCompleted)) {
//Read transaction status inquiry 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 transaction status inquiry request.
val transactionStatusRequest = TransactionStatusRequest(paymentToken).apply {
additionalInfo = true
}
//Step 3: Retrieve transaction status inquiry response.
PGWSDK.getInstance().transactionStatus(transactionStatusRequest, object : APIResponseCallback<TransactionStatusResponse> {
override fun onResponse(response: TransactionStatusResponse) {
if (response.responseCode == APIResponseCode.TransactionNotFound || response.responseCode == APIResponseCode.TransactionCompleted) {
//Read transaction status inquiry 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 transaction status inquiry request.
TransactionStatusRequest *transactionStatusRequest = [[TransactionStatusRequest alloc] initWithPaymentToken: paymentToken];
transactionStatusRequest.additionalInfo = true;
//Step 3: Retrieve transaction status inquiry response.
[[PGWSDK shared] transactionStatusWithTransactionStatusRequest: transactionStatusRequest response: ^(TransactionStatusResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.TransactionNotFound] || [response.responseCode isEqualToString: APIResponseCode.TransactionCompleted]) {
//Read transaction status inquiry 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 transaction status inquiry request.
let transactionStatusRequest: TransactionStatusRequest = TransactionStatusRequest(paymentToken: paymentToken)
transactionStatusRequest.additionalInfo = true
//Step 3: Retrieve transaction status inquiry response.
PGWSDK.shared.transactionStatus(transactionStatusRequest: transactionStatusRequest, { (response: TransactionStatusResponse) in
if response.responseCode == APIResponseCode.TransactionNotFound || response.responseCode == APIResponseCode.TransactionCompleted {
//Read transaction status inquiry 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 transaction status inquiry request.
Map<String, dynamic> transactionStatusRequest = {
'paymentToken': paymentToken,
'additionalInfo': true
};
//Step 3: Retrieve transaction status inquiry response.
PGWSDK().transactionStatus(transactionStatusRequest, (response) {
if (response['responseCode'] == APIResponseCode.transactionNotFound || response['responseCode'] == APIResponseCode.transactionCompleted) {
//Read transaction status inquiry 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 transaction status inquiry request.
let transactionStatusRequest = {
'paymentToken': paymentToken,
'additionalInfo': true
};
//Step 3: Retrieve transaction status inquiry response.
await RTNPGW.transactionStatus(JSON.stringify(transactionStatusRequest)).then((response: string) => {
let transactionStatusResponse = JSON.parse(response);
if (transactionStatusResponse?.responseCode == APIResponseCode.transactionCompleted) {
//Read transaction status inquiry response.
} else {
//Get error response and display error
}
}).catch ((error: Error) => {
//Get error response and display error
});
Updated 18 days ago