Customer Token Information
API Method
References
1. Generate Payment Token
To prepare a payment token request, refer to the required parameters below.
Payment Token APIRefer 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"],
"customerToken": ["20052010380915759367"]
}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 Customer Token Info Request
To prepare a customer token info request, refer to the parameters below.
Request API Parameters
CustomerTokenInfoRequest customerTokenInfoRequest = new CustomerTokenInfoRequest(paymentToken);val customerTokenInfoRequest = CustomerTokenInfoRequest(paymentToken)CustomerTokenInfoRequest *customerTokenInfoRequest =[[CustomerTokenInfoRequest alloc] initWithPaymentToken: paymentToken];let customerTokenInfoRequest: CustomerTokenInfoRequest = CustomerTokenInfoRequest(paymentToken: paymentToken)Map<String, dynamic> customerTokenInfoRequest = {
'paymentToken': paymentToken
};let customerTokenInfoRequest = {
'paymentToken': paymentToken
};4. Retrieve Customer Token Info Response
To retrieve a customer token information response, refer to the parameters below.
Response API Parameters
PGWSDK.getInstance().customerTokenInfo(customerTokenInfoRequest, new APIResponseCallback<CustomerTokenInfoResponse>() {
@Override
public void onResponse(CustomerTokenInfoResponse response) {
if (response.getResponseCode().equals(APIResponseCode.APISuccess)) {
//Read customer token info response.
} else {
//Get error response and display error.
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error.
}
});PGWSDK.getInstance().customerTokenInfo(customerTokenInfoRequest, object : APIResponseCallback<CustomerTokenInfoResponse> {
override fun onResponse(response: CustomerTokenInfoResponse) {
if (response.responseCode == APIResponseCode.APISuccess) {
//Read customer token info response.
} else {
//Get error response and display error.
}
}
override fun onFailure(error: Throwable) {
//Get error response and display error.
}
})[[PGWSDK shared] customerTokenInfoWithCustomerTokenInfoRequest: customerTokenInfoRequest response: ^(CustomerTokenInfoResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
//Read customer token info response.
} else {
//Get error response and display error.
}
} failure: ^(NSError * _Nonnull error) {
//Get error response and display error.
}];PGWSDK.shared.customerTokenInfo(customerTokenInfoRequest: customerTokenInfoRequest, { (response: CustomerTokenInfoResponse) in
if response.responseCode == APIResponseCode.APISuccess {
//Read customer token info response.
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}PGWSDK().customerTokenInfo(customerTokenInfoRequest, (response) {
if (response['responseCode'] == APIResponseCode.apiSuccess) {
//Read customer token info response.
} else {
//Get error response and display error.
}
}, (error) {
//Get error response and display error.
});await RTNPGW.customerTokenInfo(JSON.stringify(customerTokenInfoRequest)).then((response: string) => {
let customerTokenInfoResponse = JSON.parse(response);
if (customerTokenInfoResponse?.responseCode == APIResponseCode.apiSuccess) {
//Read customer token info 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 customer token info request.
CustomerTokenInfoRequest customerTokenInfoRequest = new CustomerTokenInfoRequest(paymentToken);
//Step 3: Retrieve customer token info response.
PGWSDK.getInstance().customerTokenInfo(customerTokenInfoRequest, new APIResponseCallback<CustomerTokenInfoResponse>() {
@Override
public void onResponse(CustomerTokenInfoResponse response) {
if (response.getResponseCode().equals(APIResponseCode.APISuccess)) {
//Read customer token info 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 customer token info request.
val customerTokenInfoRequest = CustomerTokenInfoRequest(paymentToken)
//Step 3: Retrieve customer token info response.
PGWSDK.getInstance().customerTokenInfo(customerTokenInfoRequest, object : APIResponseCallback<CustomerTokenInfoResponse> {
override fun onResponse(response: CustomerTokenInfoResponse) {
if (response.responseCode == APIResponseCode.APISuccess) {
//Read customer token info 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 customer token info request.
CustomerTokenInfoRequest *customerTokenInfoRequest =[[CustomerTokenInfoRequest alloc] initWithPaymentToken: paymentToken];
//Step 3: Retrieve customer token info response.
[[PGWSDK shared] customerTokenInfoWithCustomerTokenInfoRequest: customerTokenInfoRequest response: ^(CustomerTokenInfoResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.APISuccess]) {
//Read customer token info 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 customer token info request.
let customerTokenInfoRequest: CustomerTokenInfoRequest = CustomerTokenInfoRequest(paymentToken: paymentToken)
//Step 3: Retrieve customer token info response.
PGWSDK.shared.customerTokenInfo(customerTokenInfoRequest: customerTokenInfoRequest, { (response: CustomerTokenInfoResponse) in
if response.responseCode == APIResponseCode.APISuccess {
//Read customer token info 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 customer token info request.
Map<String, dynamic> customerTokenInfoRequest = {
'paymentToken': paymentToken
};
//Step 3: Retrieve customer token info response.
PGWSDK().customerTokenInfo(customerTokenInfoRequest, (response) {
if (response['responseCode'] == APIResponseCode.apiSuccess) {
//Read customer token info 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 customer token info request.
let customerTokenInfoRequest = {
'paymentToken': paymentToken
};
//Step 3: Retrieve customer token info response.
await RTNPGW.customerTokenInfo(JSON.stringify(customerTokenInfoRequest)).then((response: string) => {
let customerTokenInfoResponse = JSON.parse(response);
if (customerTokenInfoResponse?.responseCode == APIResponseCode.apiSuccess) {
//Read customer token info response.
} else {
//Get error response and display error
}
}).catch ((error: Error) => {
//Get error response and display error
});Updated about 1 year ago
