| | |
| | | *
|
| | | */
|
| | | public class WXPayUtil {
|
| | | |
| | | private static String post(String url,String entity)
|
| | | {
|
| | |
|
| | | private static String post(String url, String entity) {
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod method = new PostMethod(url);
|
| | | method.setRequestBody(entity);
|
| | |
| | |
|
| | | String entity = WXUtil.loadWXMessage(map);
|
| | |
|
| | | String result = post("https://api.mch.weixin.qq.com/pay/unifiedorder", entity);
|
| | | String result = HttpUtil.post("https://api.mch.weixin.qq.com/pay/unifiedorder", entity);
|
| | | try {
|
| | | System.out.println("统一下单结果:" + new String(result.getBytes("GBK"), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | Map<String, String> resultMap = WXUtil.parseXML(result);
|