获取微信沙盒秘钥

 @Test
    public void GetSandboxSignKey() throws Exception {
        String nonce_str = WXPayUtil.generateNonceStr();//生成随机字符
        Map param = new HashMap();
        param.put("mch_id", "真实商户号");//需要真实商户号
        param.put("nonce_str", nonce_str);//随机字符
        String sign = WXPayUtil.generateSignature(param,"RemianInteractiveEntertainment88", 			WXPayConstants.SignType.MD5);//通过SDK生成签名其中API_KEY为商户对应的真实密钥
        param.put("sign", sign);
        String xml = WXPayUtil.mapToXml(param);//将map转换为xml格式
        String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";//沙箱密钥获取api
        String SignKey = HttpUtil.postData(url, xml);//
        System.out.println("signkey+"+SignKey);
        Map param1 = new HashMap();
        param1 = WXPayUtil.xmlToMap(SignKey);
        String key = param1.get("sandbox_signkey");
        System.out.println(key);
    }

你可能感兴趣的:(获取微信沙盒秘钥)