Skip to content

Commit b277982

Browse files
committed
增加公众号支付信息查询接口
修改部分注释
1 parent b205b7b commit b277982

4 files changed

Lines changed: 269 additions & 4 deletions

File tree

‎weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ public interface WxMpService {
543543
void setMaxRetryTimes(int maxRetryTimes);
544544

545545
/**
546-
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=9_1)
546+
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
547547
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
548548
* @param openId 支付人openId
549549
* @param outTradeNo 商户端对应订单号
@@ -570,4 +570,11 @@ public interface WxMpService {
570570
*/
571571
Map<String, String> getJSSDKPayInfo(String openId, String outTradeNo, double amt, String body, String tradeType, String ip, String notifyUrl);
572572

573+
/**
574+
* 该接口提供所有微信支付订单的查询,当支付通知处理异常戒丢失的情冴,商户可以通过该接口查询订单支付状态。
575+
* 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
576+
* @param transactionId
577+
* @param outTradeNo
578+
*/
579+
WxMpPayResult getJSSDKPayResult(String transactionId, String outTradeNo);
573580
}

‎weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,4 +705,48 @@ public Map<String, String> getJSSDKPayInfo(String openId, String outTradeNo, dou
705705
payInfo.put("sign", finalSign);
706706
return payInfo;
707707
}
708+
709+
@Override
710+
public WxMpPayResult getJSSDKPayResult(String transactionId, String outTradeNo) {
711+
String nonce_str = System.currentTimeMillis() + "";
712+
713+
SortedMap<String, String> packageParams = new TreeMap<String, String>();
714+
packageParams.put("appid", wxMpConfigStorage.getAppId());
715+
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
716+
packageParams.put("transaction_id", transactionId);
717+
packageParams.put("out_trade_no", outTradeNo);
718+
packageParams.put("nonce_str", nonce_str);
719+
720+
String sign = WxCryptUtil.createSign(packageParams, wxMpConfigStorage.getPartnerKey());
721+
String xml = "<xml>" +
722+
"<appid>" + wxMpConfigStorage.getAppId() + "</appid>" +
723+
"<mch_id>" + wxMpConfigStorage.getPartnerId() + "</mch_id>" +
724+
"<transaction_id>" + transactionId + "</transaction_id>" +
725+
"<out_trade_no>" + outTradeNo + "</out_trade_no>" +
726+
"<nonce_str>" + nonce_str + "</nonce_str>" +
727+
"<sign>" + sign + "</sign>" +
728+
"</xml>";
729+
730+
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/pay/orderquery");
731+
if (httpProxy != null) {
732+
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
733+
httpPost.setConfig(config);
734+
}
735+
736+
StringEntity entity = new StringEntity(xml, Consts.UTF_8);
737+
httpPost.setEntity(entity);
738+
try {
739+
CloseableHttpResponse response = httpClient.execute(httpPost);
740+
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
741+
XStream xstream = XStreamInitializer.getInstance();
742+
xstream.alias("xml", WxMpPayResult.class);
743+
WxMpPayResult wxMpPayResult = (WxMpPayResult) xstream.fromXML(responseContent);
744+
return wxMpPayResult;
745+
} catch (IOException e) {
746+
e.printStackTrace();
747+
}
748+
return new WxMpPayResult();
749+
}
750+
751+
708752
}
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
package me.chanjar.weixin.mp.bean.result;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* <pre>
7+
* 查询订单支付状态返回的结果
8+
*
9+
* 查询订单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2)
10+
*
11+
* </pre>
12+
*
13+
* @author ukid
14+
*/
15+
public class WxMpPayResult implements Serializable {
16+
private String return_code;
17+
private String return_msg;
18+
private String appid;
19+
private String mch_id;
20+
private String nonce_str;
21+
private String sign;
22+
private String result_code;
23+
private String err_code;
24+
private String err_code_des;
25+
private String trade_state;
26+
private String device_info;
27+
private String openid;
28+
private String is_subscribe;
29+
private String trade_type;
30+
private String bank_type;
31+
private String total_fee;
32+
private String coupon_fee;
33+
private String fee_type;
34+
private String transaction_id;
35+
private String out_trade_no;
36+
private String attach;
37+
private String time_end;
38+
39+
public String getReturn_code() {
40+
return return_code;
41+
}
42+
43+
public String getReturn_msg() {
44+
return return_msg;
45+
}
46+
47+
public String getAppid() {
48+
return appid;
49+
}
50+
51+
public String getMch_id() {
52+
return mch_id;
53+
}
54+
55+
public String getNonce_str() {
56+
return nonce_str;
57+
}
58+
59+
public String getSign() {
60+
return sign;
61+
}
62+
63+
public String getResult_code() {
64+
return result_code;
65+
}
66+
67+
public String getErr_code() {
68+
return err_code;
69+
}
70+
71+
public String getErr_code_des() {
72+
return err_code_des;
73+
}
74+
75+
public String getTrade_state() {
76+
return trade_state;
77+
}
78+
79+
public String getDevice_info() {
80+
return device_info;
81+
}
82+
83+
public String getOpenid() {
84+
return openid;
85+
}
86+
87+
public String getIs_subscribe() {
88+
return is_subscribe;
89+
}
90+
91+
public String getTrade_type() {
92+
return trade_type;
93+
}
94+
95+
public String getBank_type() {
96+
return bank_type;
97+
}
98+
99+
public String getTotal_fee() {
100+
return total_fee;
101+
}
102+
103+
public String getCoupon_fee() {
104+
return coupon_fee;
105+
}
106+
107+
public String getFee_type() {
108+
return fee_type;
109+
}
110+
111+
public String getTransaction_id() {
112+
return transaction_id;
113+
}
114+
115+
public String getOut_trade_no() {
116+
return out_trade_no;
117+
}
118+
119+
public String getAttach() {
120+
return attach;
121+
}
122+
123+
public String getTime_end() {
124+
return time_end;
125+
}
126+
127+
public void setReturn_code(String return_code) {
128+
this.return_code = return_code;
129+
}
130+
131+
public void setReturn_msg(String return_msg) {
132+
this.return_msg = return_msg;
133+
}
134+
135+
public void setAppid(String appid) {
136+
this.appid = appid;
137+
}
138+
139+
public void setMch_id(String mch_id) {
140+
this.mch_id = mch_id;
141+
}
142+
143+
public void setNonce_str(String nonce_str) {
144+
this.nonce_str = nonce_str;
145+
}
146+
147+
public void setSign(String sign) {
148+
this.sign = sign;
149+
}
150+
151+
public void setResult_code(String result_code) {
152+
this.result_code = result_code;
153+
}
154+
155+
public void setErr_code(String err_code) {
156+
this.err_code = err_code;
157+
}
158+
159+
public void setErr_code_des(String err_code_des) {
160+
this.err_code_des = err_code_des;
161+
}
162+
163+
public void setTrade_state(String trade_state) {
164+
this.trade_state = trade_state;
165+
}
166+
167+
public void setDevice_info(String device_info) {
168+
this.device_info = device_info;
169+
}
170+
171+
public void setOpenid(String openid) {
172+
this.openid = openid;
173+
}
174+
175+
public void setIs_subscribe(String is_subscribe) {
176+
this.is_subscribe = is_subscribe;
177+
}
178+
179+
public void setTrade_type(String trade_type) {
180+
this.trade_type = trade_type;
181+
}
182+
183+
public void setBank_type(String bank_type) {
184+
this.bank_type = bank_type;
185+
}
186+
187+
public void setTotal_fee(String total_fee) {
188+
this.total_fee = total_fee;
189+
}
190+
191+
public void setCoupon_fee(String coupon_fee) {
192+
this.coupon_fee = coupon_fee;
193+
}
194+
195+
public void setFee_type(String fee_type) {
196+
this.fee_type = fee_type;
197+
}
198+
199+
public void setTransaction_id(String transaction_id) {
200+
this.transaction_id = transaction_id;
201+
}
202+
203+
public void setOut_trade_no(String out_trade_no) {
204+
this.out_trade_no = out_trade_no;
205+
}
206+
207+
public void setAttach(String attach) {
208+
this.attach = attach;
209+
}
210+
211+
public void setTime_end(String time_end) {
212+
this.time_end = time_end;
213+
}
214+
215+
}

‎weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpPrepayIdResult.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
/**
66
* <pre>
7-
* 群发消息一发送就返回的结果
7+
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果
88
*
9-
* 真正的群发消息是否发送成功要看
10-
* http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口#.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81.E7.BE.A4.E5.8F.91.E7.BB.93.E6.9E.9C
9+
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
1110
*
1211
* </pre>
1312
*

0 commit comments

Comments
 (0)