Order Status Callback Interface Specification
# Specification Description
Callback interface definition: It is the callback interface address passed in when the merchant places an order in the background. And the callback interface must receive parameters according to the following "Request Parameters".
Callback interface function: When an order ends (successfully or fails), TopPay will send a POST request to the merchant's background to notify information such as the order status change.
Callback interface constraint: After receiving the request, the merchant's background needs to return the string "success". Otherwise, TopPay will consider the callback to have failed.
# Special Notes
Callback interface verification: After receiving the request, the merchant's background needs to verify the signature using the platform's public key. Only when the verification passes can it be considered a legitimate request and business processing can be carried out.
Verification signature details: When formatting parameters, null and empty strings need to be filtered. For details, please see the TopPaySignUtil#paramFormat method code implementation.
The sample code given below is for reference only. Please modify it according to the actual situation.
Click to get the code example of TopPaySignUtil
import java.util.HashMap;
import java.util.Map;
// import TopPaySignUtil;
public class CallBack {
// The platform public key comes from the merchant's background
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUACahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB";
// Using a dictionary to receive parameters here is just an example. Please modify it according to the actual situation in actual development.
public String callBackMethod(Map<String, String> requestParams) {
// Note: Make sure to remove the sign field before formatting the request parameters.
String sign = requestParams.remove("sign");
// Format the received parameters, calculate the signature, and add the signature value to the request parameters.
String source = TopPaySignUtil.paramFormat(requestParams);
// Signature verification
boolean validReq = TopPaySignUtil.verify(PLAT_PUBLIC_KEY, source, sign);
if (!validReq) {
// ... Signature verification error
return "fail";
}
// ... Signature verification passed, execute normal business logic
return "success"; // Finally, when the processing is successful, the string "success" must be returned. Otherwise, TopPay will consider the callback to have failed.
}
}
public class TestCallBack {
public static void main(String[] args) {
Map<String, String> requestParams = new HashMap<>();
requestParams.put("platOrderNum", "S820190712000002");
requestParams.put("merchantCode", "S820211021094748000001");
requestParams.put("orderType", "1");
requestParams.put("orderNum", "T1231511321515");
requestParams.put("orderAmount", "100.00");
requestParams.put("realAmount", "99.91");
requestParams.put("status", "30");
requestParams.put("timestamp", "1745377181");
requestParams.put("utr", "HDFC1234567890");
requestParams.put("sign", "Bf8ZfHn7UyHO8TsU8Xkh2sqa0hbpKH1HSPampNXxzBn5PvJoytb8zPkHuQ...");
// Instantiate CallBack class
CallBack newObj = new CallBack();
// Call the method Output the result to the platform
String result = newObj.callBackMethod(requestParams);
System.out.println(result);
}
}
# Request Address
- Request method: POST
- Request address: Customizable
# Request Parameters
| Parameter | Required | Description | Example |
|---|---|---|---|
| platOrderNum | Y | Platform order number | S820190712000002 |
| merchantCode | Y | Merchant ID | S820211021094748000001 |
| orderType | Y | Order type | 1:pay 2:loan |
| orderNum | Y | Merchant order number | T1231511321515 |
| orderAmount | Y | Order amount(Unit: 1 rupees) | 100.00 This is the standard amount. |
| realAmount | N | User's actual payment amount(Unit: 1 rupees) | 99.01Used only when needed, and rarely used. |
| status | Y | Order status | 20: Processing 30: Success 40: Failure |
| timestamp | Y | Timestamp (seconds), Get the system real-time time stamp | 1745377181 |
| utr | N | Uniform Transaction Reference | HDFC1234567890 |
| sign | Y | Signature | Bf8ZfHn7UyHO8TsU8Xkh2sqa0hbpKH1HSPampNXxzBn5PvJoytb8zPkHuQ |
# Request Message Example
{
"platOrderNum": "S820190712000002",
"merchantCode": "S820211021094748000001",
"orderType": "1",
"orderNum": "T1231511321515",
"orderAmount": "100.00",
"realAmount": "99.01",
"status": "30",
"timestamp": "1745377181",
"utr": "HDFC1234567890",
"sign": "Bf8ZfHn7UyHO8TsU8Xkh2sqa0hbpKH1HSPampNXxzBn5PvJoytb8zPkHuQ"
}
# Response Parameters
If the processing is successful, return the string "success".
# Response Message Example
"success"