import java.io.IOException;
import net.sf.json.JSONObject;

public class Test {

    //生产环境查询接口地址
    //public static String url = "https://ordpay.fuioupay.com/td/query.fuiou"; 
    //测试环境查询接口地址
    public static String url = "https://ordpay-test.fuioupay.com/td/query.fuiou"; 
    //测试环境商户号
    public static String mchnt_cd = "0001000F0040992";
    //测试环境商户私钥
    public static String mchnt_pri_key = "";
    //测试环境商户公钥
    public static String ins_pub_key = "";

    public static void main(String[] args) {  
        try {
            postRequestTest();
        } catch (IOException e) {
            e.printStackTrace();
        }  
    }    

    private static void postRequestTest() throws IOException {  
        //查询
        QueryOrderReq query = new QueryOrderReq();
        query.setMchnt_cd(mchnt_cd);
        query.setOrder_id("F123456");
        JSONObject jsonParam = JSONObject.fromObject(query); 
        //用富友公钥加密得到密文。
        String message = RsaUtil.encryptByRsaPub(jsonParam.toString(), ins_pub_key, "UTF-8");

        CommonReq req = new CommonReq();
        req.setMchnt_cd("0002900F0096235");
        req.setMessage(message);

        JSONObject reqJson = JSONObject.fromObject(req); 
        JSONObject respJson = HttpRequestUtil.httpPost(url, reqJson);
        System.out.println("返回的报文=="+respJson);
        message = respJson.getString("message");
        //商户私钥解密出来密文
        String plain = RsaUtil.decryptByRsaPri(message, ins_pub_key, "GBK");
        System.out.println("商户私钥解密出来的明文plain=="+plain);
    }  
}

results matching ""

    No results matching ""