Java微信支付—app篇 基于springboot
一:简介
二:集成步骤
<dependency> <groupId>com.github.wxpay</groupId> <artifactId>wxpay-sdk</artifactId> <version>0.0.3</version> </dependency>
4.统一下单请求(标题4)
public class PayCommonUtil { /** * post请求并得到返回结果 * @param requestUrl * @param xml * @return */ public static String httpPostXML(String requestUrl, String xml) { CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(requestUrl); StringEntity postEntity = new StringEntity(xml, "UTF-8"); httpPost.addHeader("Content-Type", "text/xml;charset=UTF-8"); httpPost.setEntity(postEntity); try { HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); return EntityUtils.toString(entity, "UTF-8"); } catch (Exception var7) { } return ""; } } 注:注意HttpResponse 引入的包是 package org.apache.http;下面的
展示下支付页面