inquiry order code example

# codeExample


import com.google.gson.JsonObject;
public class OrderQuery {
    
    private static final String MCH_NO = "PHOT000001";  // merchantNo
    private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB";  // 平台公钥
    private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+**************************/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp";  // 商户私钥
    private static final String orderQueryUrl = "https://ph-openapi.toppayment.com/ph/disbursement/query`;

    public static void main(String[] args) throws Exception {
        
        query();
    }
    private static void query() throws Exception {
        Map<String, Object> requestParams = new TreeMap<>();
        requestParams.put("mchNo", MCH_NO);
        requestParams.put("orderNum", "186888188666"); // merchantOrderNumber
        requestParams.put("platOrderNum", "PRE186888188666"); // platOrderNum
        requestParams.put("timestamp", Long.valueOf(System.currentTimeMillis()));// timestamp  

        StringBuilder stringBuilder = new StringBuilder();
        for (String key : requestParams.keySet()) {
            stringBuilder.append(requestParams.get(key));  
        }

        String keyStr = stringBuilder.toString();  
        System.out.println("keyStr:" + keyStr);
        String signedStr = TopPayRequestUtil.privateEncrypt(keyStr, TopPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY));  
        requestParams.put("sign", signedStr);

        String postJson = new Gson().toJson(requestParams);
        System.out.println("Post Json Params:" + postJson);

        String responseJson = TopPayRequestUtil.doPost(orderQueryUrl, postJson);  //  post http json request
        System.out.println("Response Msg:" + responseJson);
    }
}

NA