Order Query
# Code example
TopPayRequestUtil Click to obtain code examples
import com.google.gson.JsonObject;
public class OrderQuery {
//MCH_ID: Merchant ID
//1.Please log in to the merchant backend
//2.Click on personal center > personal information
//3.Get Merchant ID in Basic Information
private static final String MCH_ID = "S820211021094748000001";
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // platform public key
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // merchant private key
private static final String orderQueryUrl = "https://tl-openapi.toppay.asia/gateway/query";
public static void main(String[] args) throws Exception {
// pay
query();
}
private static void query() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("queryType", "CASH_QUERY"); // payment channel
requestParams.put("orderNum", "186888188666"); // merchant order number
requestParams.put("platOrderNum", "PRE186888188666"); // platform order number
requestParams.put("dateTime", "20220101105500");// timestamp format yyyyMMddHHmmss
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // stitching parameters
}
String keyStr = stringBuilder.toString(); // get the string to be encrypted
System.out.println("keyStr:" + keyStr);
String signedStr = TopPayRequestUtil.privateEncrypt(keyStr, TopPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // private key encryption
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = TopPayRequestUtil.doPost(orderQueryUrl, postJson); // send post json request
System.out.println("Response Msg:" + responseJson);
}
}
# Request address
- Request type:
POST
- Request address:
https://tl-openapi.toppay.asia/gateway/query
# Request param
Note: Both the merchant order number and the platform order number must be passed one of them, or they can be passed at the same time
Param | required | description | example |
---|---|---|---|
merchantCode | Y | merchant code | S820190712000002 |
queryType | Y | query type | pay:ORDER_QUERY cash:CASH_QUERY |
orderNum | Y | merchant order number | T1231511321515 |
platOrderNum | Y | platform order number | PRE1234567890 |
dateTime | Y | timestamp | 20191018105510 yyyy-MM-dd HH:mm:ss |
sign | Y | RSA sign | ja6R8eukQ... |
# Request example
{
"dateTime": "20220101105500",
"merchantCode": "S820211021094748000001",
"orderNum": "T1642593166888",
"platOrderNum": "PRE1642593166888",
"queryType": "ORDER_QUERY",
"sign": "lGw1OJcuUL0MGaIq44U2u2bFM5dalJJuT/G6mQWbIBT9dmVAJaLwR125emPDXYYSdnOtNxja86A2VJJLf40BCg2HevHolebvt2ay3ukCQaUhwNkIGz4KF0Ud+XMUA36LoFTWZbDYv9y8vgCnWxwZFKj7ePrfLxc+TA7jpqv65lQ\u003d"
}
# merchantCode(format reference-sample pay order query response message)
Param | Type | Required | description | Example |
---|---|---|---|---|
success | BOOLEAN | Y | response status | true/false |
code | int | Y | response code | 1000 means success, others are failure |
message | String | Y | response message | return specific response information |
data | Json | Y | response parameters | The following parameters are all returned in data, or null if failed |
msg | String | Y | order status details | Request Transaction Success |
platOrderNum | String | Y | platform order number | PI1453242857400963072 |
amount | String | Y | money | 100.00 |
fee | string | Y | fee amount | 10.00 |
orderNum | String | Y | merchant order number | 23645782 |
inAddress | string | N | Account address | TLRx8JXsDidC7PYVLmeD6Bhk5k5CUjnPV3 |
sendAddress | String | N | Billing address | TLRx8JcxDidC7PYVLmeD6Bhk5k5CUjnPV3 |
platRespCode | String | Y | request business status | FAIL:fail\SUCCESS:succeed |
platRespMessage | String | Y | respond to information prompts | Request Transaction Success |
status | int/String | Y | order status | Click to view the order status description |
- Order query example for pay api
{
"success": true,
"code": 1000,
"message": "Success",
"data": {
"msg": "Payment Success",
"platOrderNum": "PRE1483771634191044608",
"amount": "150",
"fee": "10.00",
"orderNum": "T1642593166888",
"platRespCode": "SUCCESS",
"platRespMessage": "success",
"status": "SUCCESS"
}
}
- Order query example for cash api
{
"success": true,
"code": 1000,
"message": "Success",
"data": {
"msg": "test cash",
"platOrderNum": "W0620220119174331000001",
"amount": "125",
"fee": "10.00",
"orderNum": "186888188666",
"platRespCode": "SUCCESS",
"platRespMessage": "success",
"status": 2
}
}