├── README.md
└── 小程序微信支付
├── 小程序端
└── weixin_pay
│ ├── app.js
│ ├── app.json
│ ├── app.wxss
│ ├── pages
│ ├── index
│ │ ├── index.js
│ │ ├── index.wxml
│ │ └── index.wxss
│ └── logs
│ │ ├── logs.js
│ │ ├── logs.json
│ │ ├── logs.wxml
│ │ └── logs.wxss
│ └── utils
│ └── util.js
└── 服务端java
└── weixinpay
├── pom.xml
├── src
└── main
│ ├── java
│ └── com
│ │ └── weixinpay
│ │ ├── GetOpenId.java
│ │ ├── PayResult.java
│ │ ├── Refund.java
│ │ ├── Sign.java
│ │ ├── Xiadan.java
│ │ ├── common
│ │ ├── Configure.java
│ │ ├── HttpRequest.java
│ │ ├── MD5.java
│ │ ├── PayUtils.java
│ │ ├── RandomStringGenerator.java
│ │ ├── Signature.java
│ │ └── StreamUtil.java
│ │ ├── model
│ │ ├── OrderInfo.java
│ │ ├── OrderReturnInfo.java
│ │ └── SignInfo.java
│ │ └── sendTemplateMsg.java
│ ├── resources
│ └── log4j.properties
│ └── webapp
│ └── WEB-INF
│ └── web.xml
└── target
├── classes
├── com
│ └── weixinpay
│ │ ├── GetOpenId.class
│ │ ├── PayResult.class
│ │ ├── Sign.class
│ │ ├── Xiadan.class
│ │ ├── common
│ │ ├── Configure.class
│ │ ├── HttpRequest$MyX509TrustManager.class
│ │ ├── HttpRequest.class
│ │ ├── MD5.class
│ │ ├── RandomStringGenerator.class
│ │ ├── Signature.class
│ │ └── StreamUtil.class
│ │ └── model
│ │ ├── OrderInfo.class
│ │ ├── OrderReturnInfo.class
│ │ └── SignInfo.class
└── log4j.properties
└── m2e-wtp
└── web-resources
└── META-INF
├── MANIFEST.MF
└── maven
└── com.weixinpay
└── weixinpay
├── pom.properties
└── pom.xml
/README.md:
--------------------------------------------------------------------------------
1 | # xcx-wxpay
2 | 关于微信小程序支付、退款、模板消息发送功能的demo(前后台代码)
3 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | })
25 | }
26 | },
27 | globalData:{
28 | userInfo:null,
29 | serverUrl: "https://www.yourwebsite.com/",
30 | }
31 | })
32 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index",
4 | "pages/logs/logs"
5 | ],
6 | "window":{
7 | "backgroundTextStyle":"light",
8 | "navigationBarBackgroundColor": "#fff",
9 | "navigationBarTitleText": "WeChat",
10 | "navigationBarTextStyle":"black"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | var app = getApp()
4 | Page({
5 | data: {
6 | motto: 'Hello World',
7 | userInfo: {}
8 | },
9 | onLoad: function () {
10 | console.log('onLoad')
11 |
12 | },
13 | //
14 | payoff: function(e){
15 | var that = this;
16 | wx.login({
17 | success: function(res) {
18 | that.getOpenId(res.code);
19 | }
20 | });
21 |
22 | },
23 | //获取openid
24 | getOpenId: function(code){
25 | var that = this;
26 | wx.request({
27 | url: 'getApp().globalData.serverUrl + '/wxController.do?GetOpenId',
28 | method: 'POST',
29 | header: {
30 | 'content-type': 'application/x-www-form-urlencoded'
31 | },
32 | data: {'code':code},
33 | success: function(res) {
34 | var openId = res.data.openid;
35 | wx.setStorageSync('openid', openId);
36 | that.xiadan(openId);
37 | }
38 | })
39 | },
40 | //下单
41 | xiadan: function(openId){
42 | var that = this;
43 | wx.request({
44 | url: 'getApp().globalData.serverUrl + '/wxController.do?xiadan',
45 | method: 'POST',
46 | header: {
47 | 'content-type': 'application/x-www-form-urlencoded'
48 | },
49 | data: {'openid':openId},
50 | success: function(res) {
51 | var prepay_id = res.data.prepay_id;
52 | console.log("统一下单返回 prepay_id:"+prepay_id);
53 | that.sign(prepay_id);
54 | }
55 | })
56 | },
57 | //签名
58 | sign: function(prepay_id){
59 | var that = this;
60 | wx.request({
61 | url: 'getApp().globalData.serverUrl + '/wxController.do?sign',
62 | method: 'POST',
63 | header: {
64 | 'content-type': 'application/x-www-form-urlencoded'
65 | },
66 | data: {'repay_id':prepay_id},
67 | success: function(res) {
68 | that.requestPayment(res.data);
69 |
70 | }
71 | })
72 | },
73 | //申请支付
74 | requestPayment: function(obj){
75 | wx.requestPayment({
76 | 'timeStamp': obj.timeStamp,
77 | 'nonceStr': obj.nonceStr,
78 | 'package': obj.package,
79 | 'signType': obj.signType,
80 | 'paySign': obj.paySign,
81 | 'success':function(res){
82 |
83 | //发送支付成功的模板消息
84 | wx.request({
85 | url: getApp().globalData.serverUrl + '/wxController.do?sendTemplateMsg',
86 | method: 'POST',
87 | header: {
88 | 'content-type': 'application/x-www-form-urlencoded'
89 | },
90 | data: {
91 | 'openid': wx.getStorageSync('openId'),
92 | 'prepay_id': prepay_id,
93 | 'body': that.data.body,
94 | 'scene': scene
95 | },
96 | success: function (res) {
97 | console.log(res);
98 | }
99 | })
100 | },
101 | 'fail':function(res){
102 | }
103 | })
104 | },
105 | //退款
106 | refund: function(){
107 | var that = this;
108 | wx.request({
109 | url: 'getApp().globalData.serverUrl + '/wxController.do?refund',
110 | method: 'POST',
111 | header: {
112 | 'content-type': 'application/x-www-form-urlencoded'
113 | },
114 | data: {
115 | 'unionid': wx.getStorageSync("openid"),
116 | //需退款的订单id
117 | 'orderId':orderid
118 | },
119 | success: function(res) {
120 |
121 | }
122 | })
123 | },
124 | })
125 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .userinfo {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | }
7 |
8 | .userinfo-avatar {
9 | width: 128rpx;
10 | height: 128rpx;
11 | margin: 20rpx;
12 | border-radius: 50%;
13 | }
14 |
15 | .userinfo-nickname {
16 | color: #aaa;
17 | }
18 |
19 | .usermotto {
20 | margin-top: 200px;
21 | }
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/pages/logs/logs.js:
--------------------------------------------------------------------------------
1 | //logs.js
2 | var util = require('../../utils/util.js')
3 | Page({
4 | data: {
5 | logs: []
6 | },
7 | onLoad: function () {
8 | this.setData({
9 | logs: (wx.getStorageSync('logs') || []).map(function (log) {
10 | return util.formatTime(new Date(log))
11 | })
12 | })
13 | }
14 | })
15 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/pages/logs/logs.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看启动日志"
3 | }
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/pages/logs/logs.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{index + 1}}. {{log}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/pages/logs/logs.wxss:
--------------------------------------------------------------------------------
1 | .log-list {
2 | display: flex;
3 | flex-direction: column;
4 | padding: 40rpx;
5 | }
6 | .log-item {
7 | margin: 10rpx;
8 | }
9 |
--------------------------------------------------------------------------------
/小程序微信支付/小程序端/weixin_pay/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds()
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 | module.exports = {
20 | formatTime: formatTime
21 | }
22 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.weixinpay
5 | weixinpay
6 | war
7 | 0.0.1-SNAPSHOT
8 | weixinpay Maven Webapp
9 | http://maven.apache.org
10 |
11 |
12 | junit
13 | junit
14 | 3.8.1
15 | test
16 |
17 |
18 | javax.servlet
19 | javax.servlet-api
20 | 3.0.1
21 |
22 |
23 | log4j
24 | log4j
25 | 1.2.16
26 |
27 |
28 | org.apache.httpcomponents
29 | httpclient
30 | 4.4
31 |
32 |
33 | org.apache.httpcomponents
34 | httpcore
35 | 4.4
36 |
37 |
38 | com.thoughtworks.xstream
39 | xstream
40 | 1.4.7
41 |
42 |
43 | com.alibaba
44 | fastjson
45 | 1.2.9
46 |
47 |
48 |
49 | weixinpay
50 |
51 |
52 | org.apache.maven.plugins
53 | maven-compiler-plugin
54 | 3.5.1
55 |
56 | 1.7
57 | 1.7
58 |
59 |
60 |
61 | maven-resources-plugin
62 | 3.0.1
63 |
64 |
65 | copy-xmls
66 | process-sources
67 |
68 | copy-resources
69 |
70 |
71 | ${basedir}/target/classes
72 |
73 |
74 | ${basedir}/src/main/java
75 |
76 | **/*.xml
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/GetOpenId.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.ServletException;
6 | import javax.servlet.http.HttpServlet;
7 | import javax.servlet.http.HttpServletRequest;
8 | import javax.servlet.http.HttpServletResponse;
9 |
10 | import org.apache.http.HttpEntity;
11 | import org.apache.http.HttpResponse;
12 | import org.apache.http.client.HttpClient;
13 | import org.apache.http.client.config.RequestConfig;
14 | import org.apache.http.client.methods.HttpGet;
15 | import org.apache.http.client.methods.HttpPost;
16 | import org.apache.http.entity.StringEntity;
17 | import org.apache.http.impl.client.HttpClients;
18 | import org.apache.http.util.EntityUtils;
19 |
20 | import com.thoughtworks.xstream.XStream;
21 | import com.thoughtworks.xstream.io.xml.DomDriver;
22 | import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
23 | import com.weixinpay.common.Configure;
24 |
25 | /**
26 | * Servlet implementation class GetOpenId
27 | */
28 | public class GetOpenId extends HttpServlet {
29 | private static final long serialVersionUID = 1L;
30 |
31 | /**
32 | * @see HttpServlet#HttpServlet()
33 | */
34 | public GetOpenId() {
35 | super();
36 | }
37 |
38 | /**
39 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
40 | */
41 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
42 | String code = request.getParameter("code");
43 | HttpGet httpGet = new HttpGet("https://api.weixin.qq.com/sns/jscode2session?appid="+Configure.getAppID()+"&secret="+Configure.getSecret()+"&js_code="+code+"&grant_type=authorization_code");
44 | //设置请求器的配置
45 | HttpClient httpClient = HttpClients.createDefault();
46 | HttpResponse res = httpClient.execute(httpGet);
47 | HttpEntity entity = res.getEntity();
48 | String result = EntityUtils.toString(entity, "UTF-8");
49 | response.getWriter().append(result);
50 | }
51 |
52 | /**
53 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
54 | */
55 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
56 | // TODO Auto-generated method stub
57 | doGet(request, response);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/PayResult.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay;
2 |
3 | import java.io.IOException;
4 | import javax.servlet.ServletException;
5 | import javax.servlet.http.HttpServlet;
6 | import javax.servlet.http.HttpServletRequest;
7 | import javax.servlet.http.HttpServletResponse;
8 |
9 | import org.apache.log4j.Logger;
10 |
11 | import com.weixinpay.common.StreamUtil;
12 |
13 | /**
14 | * 接收支付结果
15 | */
16 | public class PayResult extends HttpServlet {
17 | private static final long serialVersionUID = 1L;
18 | private static final Logger L = Logger.getLogger(PayResult.class);
19 |
20 | /**
21 | * @see HttpServlet#HttpServlet()
22 | */
23 | public PayResult() {
24 | super();
25 | // TODO Auto-generated constructor stub
26 | }
27 |
28 | /**
29 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
30 | */
31 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
32 | // TODO Auto-generated method stub
33 | //response.getWriter().append("Served at: ").append(request.getContextPath());
34 |
35 | String reqParams = StreamUtil.read(request.getInputStream());
36 | L.info("-------支付结果:"+reqParams);
37 | StringBuffer sb = new StringBuffer("SUCCESSOK");
38 | response.getWriter().append(sb.toString());
39 | }
40 |
41 | /**
42 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
43 | */
44 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
45 | // TODO Auto-generated method stub
46 | doGet(request, response);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/Refund.java:
--------------------------------------------------------------------------------
1 | ......
2 | @RequestMapping(params = "refund", method = RequestMethod.POST)
3 | @Transactional
4 | public @ResponseBody Map refund(String id,String user,HttpServletRequest request) {
5 | Map result = new HashMap();
6 | String currTime = PayUtils.getCurrTime();
7 | String strTime = currTime.substring(8, currTime.length());
8 | String strRandom = PayUtils.buildRandom(4) + "";
9 | String nonceStr = strTime + strRandom;
10 | String outRefundNo = "wx@re@"+PayUtils.getTimeStamp();
11 | String outTradeNo = "";
12 | String transactionId = "";
13 |
14 | String unionId = request.getParameter("openid");
15 | String orderId = request.getParameter("orderId");
16 | String appid = ResourceUtil.getConfigByName("wx.application.appid");
17 | String mchid = ResourceUtil.getConfigByName("wx.application.mch_id");
18 | String key = ResourceUtil.getConfigByName("wx.application.mch_key");
19 | WxOrderInfoEntity orderInfoEntity = new WxOrderInfoEntity();
20 | if(StringUtil.isNotEmpty(orderId)){
21 | orderInfoEntity = orderInfoService.getEntity(WxOrderInfoEntity.class,orderId);
22 | //ProfPayLog payLog = wxappOrderService.findByPayLogId(Long.valueOf(id));
23 | int total_fee = orderInfoEntity.getTotalFee();
24 | DecimalFormat df = new DecimalFormat("0.00");
25 | //String fee = String.valueOf(df.format((float)total_fee/100));
26 | String fee = String.valueOf(total_fee);
27 | SortedMap packageParams = new TreeMap();
28 | packageParams.put("appid", appid);
29 | packageParams.put("mch_id", mchid);//微信支付分配的商户号
30 | packageParams.put("nonce_str", nonceStr);//随机字符串,不长于32位
31 | packageParams.put("op_user_id", mchid);//操作员帐号, 默认为商户号
32 | //out_refund_no只能含有数字、字母和字符_-|*@
33 | packageParams.put("out_refund_no", outRefundNo);//商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
34 | packageParams.put("out_trade_no", orderInfoEntity.getOutTradeNo());//商户侧传给微信的订单号32位
35 | packageParams.put("refund_fee", fee);
36 | packageParams.put("total_fee", fee);
37 | packageParams.put("transaction_id", transactionId);//微信生成的订单号,在支付通知中有返回
38 | String sign = PayUtils.createSign(packageParams,key);
39 |
40 | String refundUrl = "https://api.mch.weixin.qq.com/secapi/pay/refund";
41 | String xmlParam=""+
42 | ""+appid+""+
43 | ""+mchid+""+
44 | ""+nonceStr+""+
45 | ""+mchid+""+
46 | ""+outRefundNo+""+
47 | ""+orderInfoEntity.getOutTradeNo()+""+
48 | ""+fee+""+
49 | ""+fee+""+
50 | ""+transactionId+""+
51 | ""+sign+""+
52 | "";
53 | logger.info("---------xml返回:"+xmlParam);
54 | String resultStr = PayUtils.post(refundUrl, xmlParam);
55 | logger.info("---------退款返回:"+resultStr);
56 | //解析结果
57 | try {
58 | Map map = PayUtils.doXMLParse(resultStr);
59 | String returnCode = map.get("return_code").toString();
60 | if(returnCode.equals("SUCCESS")){
61 | String resultCode = map.get("result_code").toString();
62 | if(resultCode.equals("SUCCESS")){
63 | //保存退款记录
64 | WxRefundInfoEntity refundInfoEntity = new WxRefundInfoEntity();
65 | refundInfoEntity.setCreateDate(new Date());
66 | refundInfoEntity.setAppid(appid);
67 | refundInfoEntity.setMchId(mchid);
68 | refundInfoEntity.setOpUserId(mchid);
69 | refundInfoEntity.setNonceStr(nonceStr);
70 | refundInfoEntity.setSign(sign);
71 | refundInfoEntity.setOutRefundNo(outRefundNo);
72 | refundInfoEntity.setOutTradeNo(orderInfoEntity.getOutTradeNo());
73 | refundInfoEntity.setTotalFee(total_fee);
74 | refundInfoEntity.setRefundFee(total_fee);
75 | refundInfoEntity.setUnionid(unionId);
76 | wxRefundInfoService.save(refundInfoEntity);
77 | /*ProfPayLog profPayLog = new ProfPayLog();
78 | profPayLog.setCreatedAt(new Date());
79 | profPayLog.setSource(payLog.getSource());
80 | profPayLog.setTotalFee(payLog.getTotalFee());
81 | profPayLog.setTradeNo(payLog.getTradeNo());
82 | profPayLog.setTransactionId(map.get("refund_id").toString());
83 | profPayLog.setUserId(user);
84 | profPayLog.setType(ProfPayLog.Type.Refund);
85 | profPayLog = wxappOrderService.save(profPayLog);*/
86 | result.put("status", "success");
87 | }else{
88 | result.put("status", "fail");
89 | }
90 | }else{
91 | result.put("status", "fail");
92 | }
93 | } catch (Exception e) {
94 | e.printStackTrace();
95 | result.put("status", "fail");
96 | }
97 | }
98 | return result;
99 | }
100 | ....
101 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/Sign.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.ServletException;
6 | import javax.servlet.http.HttpServlet;
7 | import javax.servlet.http.HttpServletRequest;
8 | import javax.servlet.http.HttpServletResponse;
9 |
10 | import org.apache.log4j.Logger;
11 |
12 | import com.alibaba.fastjson.JSONObject;
13 | import com.weixinpay.common.Configure;
14 | import com.weixinpay.common.RandomStringGenerator;
15 | import com.weixinpay.common.Signature;
16 | import com.weixinpay.model.SignInfo;
17 |
18 | /**
19 | * 再签名
20 | */
21 | public class Sign extends HttpServlet {
22 | private static final long serialVersionUID = 1L;
23 | private static final Logger L = Logger.getLogger(Sign.class);
24 | public Sign() {
25 | super();
26 | }
27 |
28 | /**
29 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
30 | */
31 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
32 | try {
33 | String repay_id = request.getParameter("repay_id");
34 | SignInfo signInfo = new SignInfo();
35 | signInfo.setAppId(Configure.getAppID());
36 | long time = System.currentTimeMillis()/1000;
37 | signInfo.setTimeStamp(String.valueOf(time));
38 | signInfo.setNonceStr(RandomStringGenerator.getRandomStringByLength(32));
39 | signInfo.setRepay_id("prepay_id="+repay_id);
40 | signInfo.setSignType("MD5");
41 | //生成签名
42 | String sign = Signature.getSign(signInfo);
43 |
44 | JSONObject json = new JSONObject();
45 | json.put("timeStamp", signInfo.getTimeStamp());
46 | json.put("nonceStr", signInfo.getNonceStr());
47 | json.put("package", signInfo.getRepay_id());
48 | json.put("signType", signInfo.getSignType());
49 | json.put("paySign", sign);
50 | L.info("-------再签名:"+json.toJSONString());
51 | response.getWriter().append(json.toJSONString());
52 | } catch (Exception e) {
53 | // TODO Auto-generated catch block
54 | e.printStackTrace();
55 | L.error("-------", e);
56 | }
57 | }
58 |
59 | /**
60 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
61 | */
62 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
63 | // TODO Auto-generated method stub
64 | doGet(request, response);
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/Xiadan.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.ServletException;
6 | import javax.servlet.http.HttpServlet;
7 | import javax.servlet.http.HttpServletRequest;
8 | import javax.servlet.http.HttpServletResponse;
9 |
10 | import org.apache.log4j.Logger;
11 |
12 | import com.alibaba.fastjson.JSONObject;
13 | import com.thoughtworks.xstream.XStream;
14 | import com.weixinpay.common.Configure;
15 | import com.weixinpay.common.HttpRequest;
16 | import com.weixinpay.common.RandomStringGenerator;
17 | import com.weixinpay.common.Signature;
18 | import com.weixinpay.model.OrderInfo;
19 | import com.weixinpay.model.OrderReturnInfo;
20 |
21 | /**
22 | * 统一下单接口
23 | */
24 | public class Xiadan extends HttpServlet {
25 | private static final long serialVersionUID = 1L;
26 | private static final Logger L = Logger.getLogger(Xiadan.class);
27 | /**
28 | * @see HttpServlet#HttpServlet()
29 | */
30 | public Xiadan() {
31 | super();
32 | }
33 |
34 | /**
35 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
36 | */
37 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
38 | // TODO Auto-generated method stub
39 | try {
40 | String openid = request.getParameter("openid");
41 | OrderInfo order = new OrderInfo();
42 | order.setAppid(Configure.getAppID());
43 | order.setMch_id(Configure.getMch_id());
44 | order.setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
45 | order.setBody("dfdfdf");
46 | order.setOut_trade_no(RandomStringGenerator.getRandomStringByLength(32));
47 | order.setTotal_fee(10);
48 | order.setSpbill_create_ip("123.57.218.54");
49 | order.setNotify_url("https://www.see-source.com/weixinpay/PayResult");
50 | order.setTrade_type("JSAPI");
51 | order.setOpenid(openid);
52 | order.setSign_type("MD5");
53 | //生成签名
54 | String sign = Signature.getSign(order);
55 | order.setSign(sign);
56 |
57 |
58 | String result = HttpRequest.sendPost("https://api.mch.weixin.qq.com/pay/unifiedorder", order);
59 | System.out.println(result);
60 | L.info("---------下单返回:"+result);
61 | XStream xStream = new XStream();
62 | xStream.alias("xml", OrderReturnInfo.class);
63 |
64 | OrderReturnInfo returnInfo = (OrderReturnInfo)xStream.fromXML(result);
65 | JSONObject json = new JSONObject();
66 | json.put("prepay_id", returnInfo.getPrepay_id());
67 | response.getWriter().append(json.toJSONString());
68 | } catch (Exception e) {
69 | e.printStackTrace();
70 | L.error("-------", e);
71 | }
72 |
73 | }
74 |
75 | /**
76 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
77 | */
78 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
79 | // TODO Auto-generated method stub
80 | doGet(request, response);
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/common/Configure.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.common;
2 |
3 | public class Configure {
4 | private static String key = "你的商户的api秘钥";
5 |
6 | //小程序ID
7 | private static String appID = "你的小程序id";
8 | //商户号
9 | private static String mch_id = "你的商户号";
10 | //
11 | private static String secret = "你的小程序的secret";
12 |
13 | public static String getSecret() {
14 | return secret;
15 | }
16 |
17 | public static void setSecret(String secret) {
18 | Configure.secret = secret;
19 | }
20 |
21 | public static String getKey() {
22 | return key;
23 | }
24 |
25 | public static void setKey(String key) {
26 | Configure.key = key;
27 | }
28 |
29 | public static String getAppID() {
30 | return appID;
31 | }
32 |
33 | public static void setAppID(String appID) {
34 | Configure.appID = appID;
35 | }
36 |
37 | public static String getMch_id() {
38 | return mch_id;
39 | }
40 |
41 | public static void setMch_id(String mch_id) {
42 | Configure.mch_id = mch_id;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/common/HttpRequest.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.common;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.IOException;
6 | import java.security.KeyManagementException;
7 | import java.security.KeyStore;
8 | import java.security.KeyStoreException;
9 | import java.security.NoSuchAlgorithmException;
10 | import java.security.UnrecoverableKeyException;
11 | import java.security.cert.CertificateException;
12 |
13 | import javax.net.ssl.SSLContext;
14 | import javax.net.ssl.X509TrustManager;
15 |
16 | import org.apache.http.HttpEntity;
17 | import org.apache.http.HttpResponse;
18 | import org.apache.http.client.ClientProtocolException;
19 | import org.apache.http.client.HttpClient;
20 | import org.apache.http.client.config.RequestConfig;
21 | import org.apache.http.client.methods.HttpPost;
22 | import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
23 | import org.apache.http.conn.ssl.SSLContexts;
24 | import org.apache.http.entity.StringEntity;
25 | import org.apache.http.impl.client.HttpClients;
26 | import org.apache.http.util.EntityUtils;
27 |
28 | import com.thoughtworks.xstream.XStream;
29 | import com.thoughtworks.xstream.io.xml.DomDriver;
30 | import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
31 |
32 | public class HttpRequest {
33 | //连接超时时间,默认10秒
34 | private static final int socketTimeout = 10000;
35 |
36 | //传输超时时间,默认30秒
37 | private static final int connectTimeout = 30000;
38 | /**
39 | * post请求
40 | * @throws IOException
41 | * @throws ClientProtocolException
42 | * @throws NoSuchAlgorithmException
43 | * @throws KeyStoreException
44 | * @throws KeyManagementException
45 | * @throws UnrecoverableKeyException
46 | */
47 | public static String sendPost(String url, Object xmlObj) throws ClientProtocolException, IOException, UnrecoverableKeyException, KeyManagementException, KeyStoreException, NoSuchAlgorithmException {
48 |
49 |
50 |
51 | HttpPost httpPost = new HttpPost(url);
52 | //解决XStream对出现双下划线的bug
53 | XStream xStreamForRequestPostData = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("-_", "_")));
54 | xStreamForRequestPostData.alias("xml", xmlObj.getClass());
55 | //将要提交给API的数据对象转换成XML格式数据Post给API
56 | String postDataXML = xStreamForRequestPostData.toXML(xmlObj);
57 |
58 | //得指明使用UTF-8编码,否则到API服务器XML的中文不能被成功识别
59 | StringEntity postEntity = new StringEntity(postDataXML, "UTF-8");
60 | httpPost.addHeader("Content-Type", "text/xml");
61 | httpPost.setEntity(postEntity);
62 |
63 | //设置请求器的配置
64 | RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();
65 | httpPost.setConfig(requestConfig);
66 |
67 | HttpClient httpClient = HttpClients.createDefault();
68 | HttpResponse response = httpClient.execute(httpPost);
69 | HttpEntity entity = response.getEntity();
70 | String result = EntityUtils.toString(entity, "UTF-8");
71 | return result;
72 | }
73 | /**
74 | * 自定义证书管理器,信任所有证书
75 | * @author pc
76 | *
77 | */
78 | public static class MyX509TrustManager implements X509TrustManager {
79 | @Override
80 | public void checkClientTrusted(
81 | java.security.cert.X509Certificate[] arg0, String arg1)
82 | throws java.security.cert.CertificateException {
83 | // TODO Auto-generated method stub
84 |
85 | }
86 | @Override
87 | public void checkServerTrusted(
88 | java.security.cert.X509Certificate[] arg0, String arg1)
89 | throws java.security.cert.CertificateException {
90 | // TODO Auto-generated method stub
91 |
92 | }
93 | @Override
94 | public java.security.cert.X509Certificate[] getAcceptedIssuers() {
95 | // TODO Auto-generated method stub
96 | return null;
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/common/MD5.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.common;
2 |
3 | import java.security.MessageDigest;
4 |
5 | /**
6 | * User: rizenguo
7 | * Date: 2014/10/23
8 | * Time: 15:43
9 | */
10 | public class MD5 {
11 | private final static String[] hexDigits = {"0", "1", "2", "3", "4", "5", "6", "7",
12 | "8", "9", "a", "b", "c", "d", "e", "f"};
13 |
14 | /**
15 | * 转换字节数组为16进制字串
16 | * @param b 字节数组
17 | * @return 16进制字串
18 | */
19 | public static String byteArrayToHexString(byte[] b) {
20 | StringBuilder resultSb = new StringBuilder();
21 | for (byte aB : b) {
22 | resultSb.append(byteToHexString(aB));
23 | }
24 | return resultSb.toString();
25 | }
26 |
27 | /**
28 | * 转换byte到16进制
29 | * @param b 要转换的byte
30 | * @return 16进制格式
31 | */
32 | private static String byteToHexString(byte b) {
33 | int n = b;
34 | if (n < 0) {
35 | n = 256 + n;
36 | }
37 | int d1 = n / 16;
38 | int d2 = n % 16;
39 | return hexDigits[d1] + hexDigits[d2];
40 | }
41 |
42 | /**
43 | * MD5编码
44 | * @param origin 原始字符串
45 | * @return 经过MD5加密之后的结果
46 | */
47 | public static String MD5Encode(String origin) {
48 | String resultString = null;
49 | try {
50 | resultString = origin;
51 | MessageDigest md = MessageDigest.getInstance("MD5");
52 | resultString = byteArrayToHexString(md.digest(resultString.getBytes("utf-8")));
53 | } catch (Exception e) {
54 | e.printStackTrace();
55 | }
56 | return resultString;
57 | }
58 |
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/common/PayUtils.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | import java.io.BufferedReader;
4 | import java.io.ByteArrayInputStream;
5 | import java.io.File;
6 | import java.io.FileInputStream;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.io.InputStreamReader;
10 | import java.io.UnsupportedEncodingException;
11 | import java.net.URLEncoder;
12 | import java.security.KeyStore;
13 | import java.security.MessageDigest;
14 | import java.text.SimpleDateFormat;
15 | import java.util.Date;
16 | import java.util.HashMap;
17 | import java.util.Iterator;
18 | import java.util.List;
19 | import java.util.Map;
20 | import java.util.Random;
21 | import java.util.Set;
22 | import java.util.SortedMap;
23 | import java.util.TreeMap;
24 |
25 | import javax.net.ssl.SSLContext;
26 | import javax.servlet.http.HttpServletRequest;
27 | import javax.servlet.http.HttpServletResponse;
28 |
29 | import org.apache.http.HttpEntity;
30 | import org.apache.http.HttpResponse;
31 | import org.apache.http.client.methods.CloseableHttpResponse;
32 | import org.apache.http.client.methods.HttpGet;
33 | import org.apache.http.client.methods.HttpPost;
34 | import org.apache.http.conn.HttpClientConnectionManager;
35 | import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
36 | import org.apache.http.entity.StringEntity;
37 | import org.apache.http.impl.client.CloseableHttpClient;
38 | import org.apache.http.impl.client.DefaultHttpClient;
39 | import org.apache.http.impl.client.HttpClients;
40 | import org.apache.http.ssl.SSLContexts;
41 | import org.apache.http.util.EntityUtils;
42 | import org.jdom.Document;
43 | import org.jdom.Element;
44 | import org.jdom.input.SAXBuilder;
45 |
46 | import org.jeecgframework.core.util.ResourceUtil;
47 | import org.jeecgframework.core.weixinpay.common.MD5;
48 | import org.jeecgframework.p3.core.util.MD5Util;
49 |
50 | @SuppressWarnings("deprecation")
51 | public class PayUtils {
52 | private static Object Server;
53 | @SuppressWarnings("deprecation")
54 | public static DefaultHttpClient httpclient;
55 | private static SortedMap parameters;
56 |
57 | static {
58 | httpclient = new DefaultHttpClient();
59 | // httpclient = (DefaultHttpClient) HttpClientConnectionManager.getSSLInstance(httpclient);
60 | parameters = new TreeMap();
61 | }
62 |
63 | public static final String KEY_PATH = "E:/wxzf/cert/apiclient_cert.p12";
64 |
65 | /**
66 | * 把对象转换成字符串
67 | *
68 | * @param obj
69 | * @return String 转换成字符串,若对象为null,则返回空字符串.
70 | */
71 | public static String toString(Object obj) {
72 | if (obj == null)
73 | return "";
74 |
75 | return obj.toString();
76 | }
77 |
78 | /**
79 | * 把对象转换为int数值.
80 | *
81 | * @param obj
82 | * 包含数字的对象.
83 | * @return int 转换后的数值,对不能转换的对象返回0。
84 | */
85 | public static int toInt(Object obj) {
86 | int a = 0;
87 | try {
88 | if (obj != null) {
89 | a = Integer.parseInt(obj.toString());
90 | }
91 | } catch (Exception e) {
92 | e.printStackTrace();
93 | }
94 | return a;
95 | }
96 |
97 | /**
98 | * 获取从1970年开始到现在的秒数
99 | *
100 | * @param date
101 | * @return
102 | */
103 | public static String getTimeStamp() {
104 | long seconds = System.currentTimeMillis() / 1000;
105 | return String.valueOf(seconds);
106 | }
107 |
108 | /**
109 | * 获取当前时间 yyyyMMddHHmmss
110 | * @return String
111 | */
112 | public static String getCurrTime() {
113 | Date now = new Date();
114 | SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
115 | String s = outFormat.format(now);
116 | return s;
117 | }
118 |
119 | /**
120 | * 获取当前日期 yyyyMMdd
121 | * @param date
122 | * @return String
123 | */
124 | public static String formatDate(Date date) {
125 | SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
126 | String strDate = formatter.format(date);
127 | return strDate;
128 | }
129 |
130 | /**
131 | * 取出一个指定长度大小的随机正整数.
132 | * @param length int 设定所取出随机数的长度。length小于11
133 | * @return int 返回生成的随机数。
134 | */
135 | public static int buildRandom(int length) {
136 | int num = 1;
137 | double random = Math.random();
138 | if (random < 0.1) {
139 | random = random + 0.1;
140 | }
141 | for (int i = 0; i < length; i++) {
142 | num = num * 10;
143 | }
144 | return (int) ((random * num));
145 | }
146 |
147 | /**
148 | * 获取编码字符集
149 | * @param request
150 | * @param response
151 | * @return String
152 | */
153 |
154 | public static String getCharacterEncoding(HttpServletRequest request, HttpServletResponse response) {
155 |
156 | if (null == request || null == response) {
157 | return "utf-8";
158 | }
159 | String enc = request.getCharacterEncoding();
160 | if (null == enc || "".equals(enc)) {
161 | enc = response.getCharacterEncoding();
162 | }
163 | if (null == enc || "".equals(enc)) {
164 | enc = "utf-8";
165 | }
166 | return enc;
167 | }
168 |
169 | public static String URLencode(String content) {
170 | String URLencode;
171 | URLencode = replace(Server.equals(content), "+", "%20");
172 | return URLencode;
173 | }
174 |
175 | private static String replace(boolean equals, String string, String string2) {
176 | return null;
177 | }
178 |
179 | /**
180 | * 获取unix时间,从1970-01-01 00:00:00开始的秒数
181 | * @param date
182 | * @return long
183 | */
184 | public static long getUnixTime(Date date) {
185 | if (null == date) {
186 | return 0;
187 | }
188 | return date.getTime() / 1000;
189 | }
190 |
191 | public static String QRfromGoogle(String chl) {
192 | int widhtHeight = 300;
193 | String EC_level = "L";
194 | int margin = 0;
195 | String QRfromGoogle;
196 | chl = URLencode(chl);
197 | QRfromGoogle = "http://chart.apis.google.com/chart?chs=" + widhtHeight + "x" + widhtHeight + "&cht=qr&chld="
198 | + EC_level + "|" + margin + "&chl=" + chl;
199 | return QRfromGoogle;
200 | }
201 |
202 | /**
203 | * 时间转换成字符串
204 | * @param date 时间
205 | * @param formatType 格式化类型
206 | * @return String
207 | */
208 | public static String date2String(Date date, String formatType) {
209 | SimpleDateFormat sdf = new SimpleDateFormat(formatType);
210 | return sdf.format(date);
211 | }
212 |
213 |
214 |
215 | /**
216 | * 创建签名SHA1
217 | * @param signParams
218 | * @return
219 | * @throws Exception
220 | */
221 | public static String createSHA1Sign(SortedMap signParams) throws Exception {
222 | StringBuffer sb = new StringBuffer();
223 | Set es = signParams.entrySet();
224 | Iterator it = es.iterator();
225 | while (it.hasNext()) {
226 | Map.Entry entry = (Map.Entry) it.next();
227 | String k = (String) entry.getKey();
228 | String v = (String) entry.getValue();
229 | sb.append(k + "=" + v + "&");
230 | // 要采用URLENCODER的原始值!
231 | }
232 | String params = sb.substring(0, sb.lastIndexOf("&"));
233 | return getSha1(params);
234 | }
235 |
236 | /**
237 | * Sha1签名
238 | * @param str
239 | * @return
240 | */
241 | public static String getSha1(String str) {
242 | if (str == null || str.length() == 0) {
243 | return null;
244 | }
245 | char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
246 | try {
247 | MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
248 | mdTemp.update(str.getBytes("UTF-8"));
249 |
250 | byte[] md = mdTemp.digest();
251 | int j = md.length;
252 | char buf[] = new char[j * 2];
253 | int k = 0;
254 | for (int i = 0; i < j; i++) {
255 | byte byte0 = md[i];
256 | buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
257 | buf[k++] = hexDigits[byte0 & 0xf];
258 | }
259 | return new String(buf);
260 | } catch (Exception e) {
261 | e.printStackTrace();
262 | return null;
263 | }
264 | }
265 |
266 | /**
267 | * 获得预支付订单号
268 | * @param url
269 | * @param xmlParam
270 | * @return
271 | */
272 | public static String getPayNo(String url, String xmlParam) {
273 | String prepay_id = "";
274 | try {
275 | String jsonStr = postWithXmlParams(url, xmlParam);
276 | if (jsonStr.indexOf("FAIL") != -1) {
277 | return prepay_id;
278 | }
279 | Map map = doXMLParse(jsonStr);
280 | prepay_id = (String) map.get("prepay_id");
281 | System.out.println("prepay_id:" + prepay_id);
282 | } catch (Exception e) {
283 | e.printStackTrace();
284 | }
285 | return prepay_id;
286 | }
287 |
288 | /**
289 | * 发送请求
290 | * @param url 请求路径
291 | * @param xmlParams xml字符串
292 | * @return
293 | */
294 | public static String postWithXmlParams(String url, String xmlParams) {
295 | HttpPost httpost = new HttpPost(url);
296 | try {
297 | httpost.setEntity(new StringEntity(xmlParams, "UTF-8"));
298 | HttpResponse response = httpclient.execute(httpost);
299 | return EntityUtils.toString(response.getEntity(), "UTF-8");
300 | } catch (Exception e) {
301 | e.printStackTrace();
302 | return "";
303 | }
304 | }
305 |
306 | /**
307 | * 解析xml,返回第一级元素键值对。如果第一级元素有子节点,则此节点的值是子节点的xml数据。
308 | * @param strxml
309 | * @return
310 | * @throws JDOMException
311 | * @throws IOException
312 | */
313 | public static Map doXMLParse(String strxml) throws Exception {
314 | if (null == strxml || "".equals(strxml)) {
315 | return null;
316 | }
317 | Map m = new HashMap();
318 | InputStream in = String2Inputstream(strxml);
319 | SAXBuilder builder = new SAXBuilder();
320 | Document doc = builder.build(in);
321 | Element root = doc.getRootElement();
322 | List list = root.getChildren();
323 | Iterator it = list.iterator();
324 | while (it.hasNext()) {
325 | Element e = (Element) it.next();
326 | String k = e.getName();
327 | String v = "";
328 | List children = e.getChildren();
329 | if (children.isEmpty()) {
330 | v = e.getTextNormalize();
331 | } else {
332 | v = getChildrenText(children);
333 | }
334 | m.put(k, v);
335 | }
336 | // 关闭流
337 | in.close();
338 | return m;
339 | }
340 |
341 | /**
342 | * 获取子结点的xml
343 | * @param children
344 | * @return String
345 | */
346 | public static String getChildrenText(List children) {
347 | StringBuffer sb = new StringBuffer();
348 | if (!children.isEmpty()) {
349 | Iterator it = children.iterator();
350 | while (it.hasNext()) {
351 | Element e = (Element) it.next();
352 | String name = e.getName();
353 | String value = e.getTextNormalize();
354 | List list = e.getChildren();
355 | sb.append("<" + name + ">");
356 | if (!list.isEmpty()) {
357 | sb.append(getChildrenText(list));
358 | }
359 | sb.append(value);
360 | sb.append("" + name + ">");
361 | }
362 | }
363 | return sb.toString();
364 | }
365 |
366 | public static InputStream String2Inputstream(String str) {
367 | return new ByteArrayInputStream(str.getBytes());
368 | }
369 |
370 | public String getParameter(String parameter) {
371 | String s = (String) this.parameters.get(parameter);
372 | return (null == s) ? "" : s;
373 | }
374 |
375 | /**
376 | * 特殊字符处理
377 | * @param src
378 | * @return
379 | * @throws UnsupportedEncodingException
380 | */
381 | public String UrlEncode(String src) throws UnsupportedEncodingException {
382 | return URLEncoder.encode(src, "UTF-8").replace("+", "%20");
383 | }
384 |
385 | /**
386 | * 获取package的签名包
387 | * @param packageParams
388 | * @param key
389 | * @return
390 | * @throws UnsupportedEncodingException
391 | */
392 | public String genPackage(SortedMap packageParams, String key) throws UnsupportedEncodingException {
393 | String sign = createSign(packageParams, key);
394 |
395 | StringBuffer sb = new StringBuffer();
396 | Set es = packageParams.entrySet();
397 | Iterator it = es.iterator();
398 | while (it.hasNext()) {
399 | Map.Entry entry = (Map.Entry) it.next();
400 | String k = (String) entry.getKey();
401 | String v = (String) entry.getValue();
402 | sb.append(k + "=" + UrlEncode(v) + "&");
403 | }
404 |
405 | // 去掉最后一个&
406 | String packageValue = sb.append("sign=" + sign).toString();
407 | return packageValue;
408 | }
409 |
410 | /**
411 | * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。
412 | */
413 | public static String createSign(SortedMap packageParams, String key) {
414 | StringBuffer sb = new StringBuffer();
415 | Set es = packageParams.entrySet();
416 | Iterator it = es.iterator();
417 | while (it.hasNext()) {
418 | Map.Entry entry = (Map.Entry) it.next();
419 | String k = (String) entry.getKey();
420 | String v = (String) entry.getValue();
421 | if (null != v && !"".equals(v) && !"sign".equals(k) && !"key".equals(k)) {
422 | sb.append(k + "=" + v + "&");
423 | }
424 | }
425 | sb.append("key=" + key);
426 | System.out.println("md5:" + sb.toString());
427 | String sign = MD5.MD5Encode(sb.toString()).toUpperCase();
428 | System.out.println("packge签名:" + sign);
429 | return sign;
430 |
431 | }
432 |
433 | /**
434 | * 创建package签名
435 | */
436 | public boolean createMd5Sign(String signParams) {
437 | StringBuffer sb = new StringBuffer();
438 | Set es = this.parameters.entrySet();
439 | Iterator it = es.iterator();
440 | while (it.hasNext()) {
441 | Map.Entry entry = (Map.Entry) it.next();
442 | String k = (String) entry.getKey();
443 | String v = (String) entry.getValue();
444 | if (!"sign".equals(k) && null != v && !"".equals(v)) {
445 | sb.append(k + "=" + v + "&");
446 | }
447 | }
448 |
449 | // 算出摘要
450 | String sign = MD5.MD5Encode(sb.toString()).toUpperCase();
451 | String paySign = this.getParameter("sign").toLowerCase();
452 | return paySign.equals(sign);
453 | }
454 |
455 | /**
456 | * 输出XML
457 | * @return
458 | */
459 | public String parseXML() {
460 | StringBuffer sb = new StringBuffer();
461 | sb.append("");
462 | Set es = this.parameters.entrySet();
463 | Iterator it = es.iterator();
464 | while (it.hasNext()) {
465 | Map.Entry entry = (Map.Entry) it.next();
466 | String k = (String) entry.getKey();
467 | String v = (String) entry.getValue();
468 | if (null != v && !"".equals(v) && !"appkey".equals(k)) {
469 |
470 | sb.append("<" + k + ">" + getParameter(k) + "" + k + ">\n");
471 | }
472 | }
473 | sb.append("");
474 | return sb.toString();
475 | }
476 |
477 | public static String post(String url, String xmlParam) {
478 | StringBuilder sb = new StringBuilder();
479 | try {
480 | KeyStore keyStore = KeyStore.getInstance("PKCS12");
481 | FileInputStream instream = new FileInputStream(new File(KEY_PATH));
482 | String mchid = ResourceUtil.getConfigByName("wx.application.mch_id");
483 | try {
484 | keyStore.load(instream, mchid.toCharArray());
485 | } finally {
486 | instream.close();
487 | }
488 |
489 | // 证书
490 | SSLContext sslcontext = SSLContexts.custom()
491 | .loadKeyMaterial(keyStore, mchid.toCharArray())
492 | .build();
493 | // 只允许TLSv1协议
494 | SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
495 | sslcontext,
496 | new String[]{"TLSv1"},
497 | null,
498 | SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
499 | //创建基于证书的httpClient,后面要用到
500 | CloseableHttpClient client = HttpClients.custom()
501 | .setSSLSocketFactory(sslsf)
502 | .build();
503 |
504 | HttpPost httpPost = new HttpPost(url);//退款接口
505 | StringEntity reqEntity = new StringEntity(xmlParam);
506 | // 设置类型
507 | reqEntity.setContentType("application/x-www-form-urlencoded");
508 | httpPost.setEntity(reqEntity);
509 | CloseableHttpResponse response = client.execute(httpPost);
510 | try {
511 | HttpEntity entity = response.getEntity();
512 | System.out.println(response.getStatusLine());
513 | if (entity != null) {
514 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));
515 | String text = "";
516 | while ((text = bufferedReader.readLine()) != null) {
517 | sb.append(text);
518 | }
519 | }
520 | EntityUtils.consume(entity);
521 | } catch (Exception e) {
522 | e.printStackTrace();
523 | } finally {
524 | try {
525 | response.close();
526 | } catch (IOException e) {
527 | e.printStackTrace();
528 | }
529 | }
530 | /*try {
531 |
532 | HttpGet httpget = new HttpGet("https://api.mch.weixin.qq.com/secapi/pay/refund");
533 |
534 | System.out.println("executing request" + httpget.getRequestLine());
535 |
536 | CloseableHttpResponse response = httpclient.execute(httpget);
537 | try {
538 | HttpEntity entity = response.getEntity();
539 |
540 | System.out.println("----------------------------------------");
541 | System.out.println(response.getStatusLine());
542 | if (entity != null) {
543 | System.out.println("Response content length: " + entity.getContentLength());
544 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));
545 | String text;
546 | while ((text = bufferedReader.readLine()) != null) {
547 | System.out.println(text);
548 | sb.append(text);
549 | }
550 |
551 | }
552 | EntityUtils.consume(entity);
553 | } finally {
554 | response.close();
555 | }
556 | } finally {
557 | httpclient.close();
558 | }*/
559 | } catch (Exception e) {
560 | e.printStackTrace();
561 | }
562 | return sb.toString();
563 | }
564 | }
565 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/common/RandomStringGenerator.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.common;
2 |
3 | import java.util.Random;
4 |
5 | /**
6 | * 随机字符串生成
7 | * @author zuoliangzhu
8 | *
9 | */
10 | public class RandomStringGenerator {
11 | /**
12 | * 获取一定长度的随机字符串
13 | * @param length 指定字符串长度
14 | * @return 一定长度的字符串
15 | */
16 | public static String getRandomStringByLength(int length) {
17 | String base = "abcdefghijklmnopqrstuvwxyz0123456789";
18 | Random random = new Random();
19 | StringBuffer sb = new StringBuffer();
20 | for (int i = 0; i < length; i++) {
21 | int number = random.nextInt(base.length());
22 | sb.append(base.charAt(number));
23 | }
24 | return sb.toString();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/common/Signature.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.common;
2 |
3 | import java.lang.reflect.Field;
4 | import java.util.ArrayList;
5 | import java.util.Arrays;
6 | import java.util.Map;
7 |
8 | import org.apache.log4j.Logger;
9 |
10 | import com.thoughtworks.xstream.annotations.XStreamAlias;
11 |
12 |
13 | /**
14 | * 签名
15 | * @author zuoliangzhu
16 | *
17 | */
18 | public class Signature {
19 | private static final Logger L = Logger.getLogger(Signature.class);
20 | /**
21 | * 签名算法
22 | * @param o 要参与签名的数据对象
23 | * @return 签名
24 | * @throws IllegalAccessException
25 | */
26 | public static String getSign(Object o) throws IllegalAccessException {
27 | ArrayList list = new ArrayList();
28 | Class cls = o.getClass();
29 | Field[] fields = cls.getDeclaredFields();
30 | for (Field f : fields) {
31 | f.setAccessible(true);
32 | if (f.get(o) != null && f.get(o) != "") {
33 | String name = f.getName();
34 | XStreamAlias anno = f.getAnnotation(XStreamAlias.class);
35 | if(anno != null)
36 | name = anno.value();
37 | list.add(name + "=" + f.get(o) + "&");
38 | }
39 | }
40 | int size = list.size();
41 | String [] arrayToSort = list.toArray(new String[size]);
42 | Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
43 | StringBuilder sb = new StringBuilder();
44 | for(int i = 0; i < size; i ++) {
45 | sb.append(arrayToSort[i]);
46 | }
47 | String result = sb.toString();
48 | result += "key=" + Configure.getKey();
49 | System.out.println("签名数据:"+result);
50 | result = MD5.MD5Encode(result).toUpperCase();
51 | return result;
52 | }
53 |
54 | public static String getSign(Map map){
55 | ArrayList list = new ArrayList();
56 | for(Map.Entry entry:map.entrySet()){
57 | if(entry.getValue()!=""){
58 | list.add(entry.getKey() + "=" + entry.getValue() + "&");
59 | }
60 | }
61 | int size = list.size();
62 | String [] arrayToSort = list.toArray(new String[size]);
63 | Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
64 | StringBuilder sb = new StringBuilder();
65 | for(int i = 0; i < size; i ++) {
66 | sb.append(arrayToSort[i]);
67 | }
68 | String result = sb.toString();
69 | result += "key=" + Configure.getKey();
70 | //Util.log("Sign Before MD5:" + result);
71 | result = MD5.MD5Encode(result).toUpperCase();
72 | //Util.log("Sign Result:" + result);
73 | return result;
74 | }
75 |
76 |
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/common/StreamUtil.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.common;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.InputStream;
5 |
6 | public class StreamUtil {
7 | public static String read(InputStream is){
8 | try {
9 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
10 | int len = 0;
11 | byte[] buffer = new byte[512];
12 | while((len = is.read(buffer)) != -1){
13 | baos.write(buffer, 0, len);
14 | }
15 | return new String(baos.toByteArray(), 0, baos.size(), "utf-8");
16 | }catch (Exception e) {
17 | // TODO Auto-generated catch block
18 | e.printStackTrace();
19 | }
20 | return "";
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/model/OrderInfo.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.model;
2 |
3 | /**
4 | * 预订单
5 | *
6 | * @author zuoliangzhu
7 | *
8 | */
9 | public class OrderInfo {
10 | private String appid;// 小程序ID
11 | private String mch_id;// 商户号
12 | private String nonce_str;// 随机字符串
13 | private String sign_type;//签名类型
14 | private String sign;// 签名
15 | private String body;// 商品描述
16 | private String out_trade_no;// 商户订单号
17 | private int total_fee;// 标价金额 ,单位为分
18 | private String spbill_create_ip;// 终端IP
19 | private String notify_url;// 通知地址
20 | private String trade_type;// 交易类型
21 | private String openid;//用户标识
22 |
23 | public String getSign_type() {
24 | return sign_type;
25 | }
26 |
27 | public void setSign_type(String sign_type) {
28 | this.sign_type = sign_type;
29 | }
30 |
31 | public String getOpenid() {
32 | return openid;
33 | }
34 |
35 | public void setOpenid(String openid) {
36 | this.openid = openid;
37 | }
38 |
39 | public String getAppid() {
40 | return appid;
41 | }
42 |
43 | public void setAppid(String appid) {
44 | this.appid = appid;
45 | }
46 |
47 | public String getMch_id() {
48 | return mch_id;
49 | }
50 |
51 | public void setMch_id(String mch_id) {
52 | this.mch_id = mch_id;
53 | }
54 |
55 | public String getNonce_str() {
56 | return nonce_str;
57 | }
58 |
59 | public void setNonce_str(String nonce_str) {
60 | this.nonce_str = nonce_str;
61 | }
62 |
63 | public String getSign() {
64 | return sign;
65 | }
66 |
67 | public void setSign(String sign) {
68 | this.sign = sign;
69 | }
70 |
71 | public String getBody() {
72 | return body;
73 | }
74 |
75 | public void setBody(String body) {
76 | this.body = body;
77 | }
78 |
79 | public String getOut_trade_no() {
80 | return out_trade_no;
81 | }
82 |
83 | public void setOut_trade_no(String out_trade_no) {
84 | this.out_trade_no = out_trade_no;
85 | }
86 |
87 | public int getTotal_fee() {
88 | return total_fee;
89 | }
90 |
91 | public void setTotal_fee(int total_fee) {
92 | this.total_fee = total_fee;
93 | }
94 |
95 | public String getSpbill_create_ip() {
96 | return spbill_create_ip;
97 | }
98 |
99 | public void setSpbill_create_ip(String spbill_create_ip) {
100 | this.spbill_create_ip = spbill_create_ip;
101 | }
102 |
103 | public String getNotify_url() {
104 | return notify_url;
105 | }
106 |
107 | public void setNotify_url(String notify_url) {
108 | this.notify_url = notify_url;
109 | }
110 |
111 | public String getTrade_type() {
112 | return trade_type;
113 | }
114 |
115 | public void setTrade_type(String trade_type) {
116 | this.trade_type = trade_type;
117 | }
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/model/OrderReturnInfo.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.model;
2 |
3 | public class OrderReturnInfo {
4 | private String return_code;
5 | private String return_msg;
6 | private String result_code;
7 | private String appid;
8 | private String mch_id;
9 | private String nonce_str;
10 | private String sign;
11 | private String prepay_id;
12 | private String trade_type;
13 | public String getReturn_code() {
14 | return return_code;
15 | }
16 | public void setReturn_code(String return_code) {
17 | this.return_code = return_code;
18 | }
19 | public String getReturn_msg() {
20 | return return_msg;
21 | }
22 | public void setReturn_msg(String return_msg) {
23 | this.return_msg = return_msg;
24 | }
25 | public String getResult_code() {
26 | return result_code;
27 | }
28 | public void setResult_code(String result_code) {
29 | this.result_code = result_code;
30 | }
31 | public String getAppid() {
32 | return appid;
33 | }
34 | public void setAppid(String appid) {
35 | this.appid = appid;
36 | }
37 | public String getMch_id() {
38 | return mch_id;
39 | }
40 | public void setMch_id(String mch_id) {
41 | this.mch_id = mch_id;
42 | }
43 | public String getNonce_str() {
44 | return nonce_str;
45 | }
46 | public void setNonce_str(String nonce_str) {
47 | this.nonce_str = nonce_str;
48 | }
49 | public String getSign() {
50 | return sign;
51 | }
52 | public void setSign(String sign) {
53 | this.sign = sign;
54 | }
55 | public String getPrepay_id() {
56 | return prepay_id;
57 | }
58 | public void setPrepay_id(String prepay_id) {
59 | this.prepay_id = prepay_id;
60 | }
61 | public String getTrade_type() {
62 | return trade_type;
63 | }
64 | public void setTrade_type(String trade_type) {
65 | this.trade_type = trade_type;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/model/SignInfo.java:
--------------------------------------------------------------------------------
1 | package com.weixinpay.model;
2 |
3 | import com.thoughtworks.xstream.annotations.XStreamAlias;
4 |
5 | /**
6 | * 签名信息
7 | * @author zuoliangzhu
8 | *
9 | */
10 | public class SignInfo {
11 |
12 | private String appId;//小程序ID
13 | private String timeStamp;//时间戳
14 | private String nonceStr;//随机串
15 | @XStreamAlias("package")
16 | private String repay_id;
17 | private String signType;//签名方式
18 |
19 | public String getAppId() {
20 | return appId;
21 | }
22 | public void setAppId(String appId) {
23 | this.appId = appId;
24 | }
25 | public String getTimeStamp() {
26 | return timeStamp;
27 | }
28 | public void setTimeStamp(String timeStamp) {
29 | this.timeStamp = timeStamp;
30 | }
31 | public String getNonceStr() {
32 | return nonceStr;
33 | }
34 | public void setNonceStr(String nonceStr) {
35 | this.nonceStr = nonceStr;
36 | }
37 | public String getRepay_id() {
38 | return repay_id;
39 | }
40 | public void setRepay_id(String repay_id) {
41 | this.repay_id = repay_id;
42 | }
43 | public String getSignType() {
44 | return signType;
45 | }
46 | public void setSignType(String signType) {
47 | this.signType = signType;
48 | }
49 |
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/java/com/weixinpay/sendTemplateMsg.java:
--------------------------------------------------------------------------------
1 |
2 | ........................
3 | /**
4 | * 发送支付成功后的模板消息
5 | * */
6 | @RequestMapping(params = "sendZFTemplateMsg",method = RequestMethod.POST)
7 | @ResponseBody
8 | public void sendZFTemplateMsg(HttpServletRequest request){
9 | String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send";
10 | String access_token = "";
11 | //取access_token
12 | List accessTokenEntityList = accessTokenService.getList(WxAccessTokenEntity.class);
13 | if(accessTokenEntityList.size() > 0) {
14 | WxAccessTokenEntity atEntity = accessTokenEntityList.get(0);
15 | access_token = atEntity.getAccessToken();
16 | }
17 |
18 | url = url + "?access_token=" + access_token;
19 | String touser = request.getParameter("openid");
20 | //选取的模板消息id,进入小程序公众后台可得
21 | String template_id = "SoIUJGDHDb_4D4Lu3sb9b1TdIw-0MF3UJHYGvVzcC4Y";
22 | //支付时下单而得的prepay_id
23 | String form_id = request.getParameter("prepay_id");
24 | String body = request.getParameter("body");
25 | String scene = request.getParameter("scene");
26 | Date curDate = new Date();
27 | String curDateStr = DateUtils.date2Str(curDate,DateUtils.time_sdf);
28 | StringBuffer buffer = new StringBuffer();
29 | //按照官方api的要求提供params
30 | buffer.append("{");
31 | buffer.append(String.format("\"touser\":\"%s\"", touser)).append(",");
32 | buffer.append(String.format("\"template_id\":\"%s\"", template_id)).append(",");
33 | buffer.append(String.format("\"page\":\"%s\"", "pages/course/course")).append(",");
34 | buffer.append(String.format("\"form_id\":\"%s\"", form_id)).append(",");
35 | buffer.append("\"data\":{");
36 | buffer.append(String.format("\"%s\": {\"value\":\"%s\",\"color\":\"%s\"},","keyword1", curDateStr, "#173177"));
37 | buffer.append(String.format("\"%s\": {\"value\":\"%s\",\"color\":\"%s\"},","keyword2", body, "#173177"));
38 | buffer.append(String.format("\"%s\": {\"value\":\"%s\",\"color\":\"%s\"}","keyword3", gymName, "#173177"));
39 | buffer.append("}");
40 | buffer.append("}");
41 | String params = "";
42 | try {
43 | params = new String(buffer.toString().getBytes("UTF-8"));
44 | System.out.println("utf-8 编码:" + params) ;
45 | } catch (UnsupportedEncodingException e) {
46 | e.printStackTrace();
47 | }
48 | String sr = HttpRequest.sendPost(url,params);
49 | System.out.println("模板消息返回——" + sr);
50 | }
51 | ....................
52 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger = DEBUG,file,stdout
2 |
3 | log4j.appender.file = org.apache.log4j.RollingFileAppender
4 | log4j.appender.file.File = /Users/zuoliangzhu/logs/weixinpay.log
5 | log4j.appender.file.MaxFileSize = 10MB
6 | log4j.appender.file.MaxBackupIndex = 20
7 | log4j.appender.file.Append = true
8 | log4j.appender.file.layout = org.apache.log4j.PatternLayout
9 | log4j.appender.file.layout.ConversionPattern = %-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] [%t] (%F\:%L)->%m %n
10 |
11 | log4j.appender.stdout = org.apache.log4j.ConsoleAppender
12 | log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 | Archetype Created Web Application
7 |
8 | Xiadan
9 | Xiadan
10 |
11 | com.weixinpay.Xiadan
12 |
13 |
14 | Sign
15 | Sign
16 |
17 | com.weixinpay.Sign
18 |
19 |
20 | PayResult
21 | PayResult
22 |
23 | com.weixinpay.PayResult
24 |
25 |
26 | GetOpenId
27 | GetOpenId
28 |
29 | com.weixinpay.GetOpenId
30 |
31 |
32 | Xiadan
33 | /xiadan
34 |
35 |
36 | Sign
37 | /sign
38 |
39 |
40 | PayResult
41 | /PayResult
42 |
43 |
44 | GetOpenId
45 | /GetOpenId
46 |
47 |
48 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/GetOpenId.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/GetOpenId.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/PayResult.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/PayResult.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/Sign.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/Sign.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/Xiadan.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/Xiadan.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/Configure.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/Configure.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/HttpRequest$MyX509TrustManager.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/HttpRequest$MyX509TrustManager.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/HttpRequest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/HttpRequest.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/MD5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/MD5.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/RandomStringGenerator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/RandomStringGenerator.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/Signature.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/Signature.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/StreamUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/common/StreamUtil.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/model/OrderInfo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/model/OrderInfo.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/model/OrderReturnInfo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/model/OrderReturnInfo.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/model/SignInfo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KevinYounGa/xcx-wxpay/6d817035181e79194bb5c07daa9b68ecb764140b/小程序微信支付/服务端java/weixinpay/target/classes/com/weixinpay/model/SignInfo.class
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/classes/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger = DEBUG,file,stdout
2 |
3 | log4j.appender.file = org.apache.log4j.RollingFileAppender
4 | log4j.appender.file.File = /Users/zuoliangzhu/logs/weixinpay.log
5 | log4j.appender.file.MaxFileSize = 10MB
6 | log4j.appender.file.MaxBackupIndex = 20
7 | log4j.appender.file.Append = true
8 | log4j.appender.file.layout = org.apache.log4j.PatternLayout
9 | log4j.appender.file.layout.ConversionPattern = %-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] [%t] (%F\:%L)->%m %n
10 |
11 | log4j.appender.stdout = org.apache.log4j.ConsoleAppender
12 | log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Built-By: zuoliangzhu
3 | Build-Jdk: 1.8.0_92
4 | Created-By: Maven Integration for Eclipse
5 |
6 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/m2e-wtp/web-resources/META-INF/maven/com.weixinpay/weixinpay/pom.properties:
--------------------------------------------------------------------------------
1 | #Generated by Maven Integration for Eclipse
2 | #Thu Jan 19 14:30:10 CST 2017
3 | version=0.0.1-SNAPSHOT
4 | groupId=com.weixinpay
5 | m2e.projectName=weixinpay
6 | m2e.projectLocation=/Users/zuoliangzhu/java/eclipse/workspace2016/weixinpay
7 | artifactId=weixinpay
8 |
--------------------------------------------------------------------------------
/小程序微信支付/服务端java/weixinpay/target/m2e-wtp/web-resources/META-INF/maven/com.weixinpay/weixinpay/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.weixinpay
5 | weixinpay
6 | war
7 | 0.0.1-SNAPSHOT
8 | weixinpay Maven Webapp
9 | http://maven.apache.org
10 |
11 |
12 | junit
13 | junit
14 | 3.8.1
15 | test
16 |
17 |
18 | javax.servlet
19 | javax.servlet-api
20 | 3.0.1
21 |
22 |
23 | log4j
24 | log4j
25 | 1.2.16
26 |
27 |
28 | org.apache.httpcomponents
29 | httpclient
30 | 4.3.5
31 |
32 |
33 | com.thoughtworks.xstream
34 | xstream
35 | 1.4.7
36 |
37 |
38 | com.alibaba
39 | fastjson
40 | 1.2.9
41 |
42 |
43 |
44 | weixinpay
45 |
46 |
47 | org.apache.maven.plugins
48 | maven-compiler-plugin
49 | 3.5.1
50 |
51 | 1.7
52 | 1.7
53 |
54 |
55 |
56 | maven-resources-plugin
57 | 3.0.1
58 |
59 |
60 | copy-xmls
61 | process-sources
62 |
63 | copy-resources
64 |
65 |
66 | ${basedir}/target/classes
67 |
68 |
69 | ${basedir}/src/main/java
70 |
71 | **/*.xml
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------