Skip to content

Commit 41da9e1

Browse files
committed
微信订单支付回掉功能完善
1 parent 7a4ca6f commit 41da9e1

18 files changed

+962
-379
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpConfigStorage.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder;
55

66
import javax.net.ssl.SSLContext;
7+
78
import java.io.File;
89
import java.util.concurrent.locks.Lock;
910

@@ -81,6 +82,23 @@ public interface WxMpConfigStorage {
8182
String getPartnerId();
8283

8384
String getPartnerKey();
85+
86+
/**
87+
* 微信支付异步回掉地址,通知url必须为直接可访问的url,不能携带参数。
88+
* @since 2.5.0
89+
* @return
90+
*/
91+
String getNotifyURL();
92+
93+
/**
94+
* 交易类型
95+
* <pre>
96+
* JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付
97+
* </pre>
98+
* @since 2.5.0
99+
* @return
100+
*/
101+
String getTradeType();
84102

85103
String getToken();
86104

@@ -112,4 +130,5 @@ public interface WxMpConfigStorage {
112130
* 是否自动刷新token
113131
*/
114132
boolean autoRefreshToken();
133+
115134
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInMemoryConfigStorage.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
2020
protected volatile String secret;
2121
protected volatile String partnerId;
2222
protected volatile String partnerKey;
23+
protected volatile String notifyURL;
24+
protected volatile String tradeType;
2325
protected volatile String token;
2426
protected volatile String accessToken;
2527
protected volatile String aesKey;
@@ -267,8 +269,25 @@ public String getPartnerKey() {
267269
public void setPartnerKey(String partnerKey) {
268270
this.partnerKey = partnerKey;
269271
}
272+
273+
274+
public String getNotifyURL() {
275+
return notifyURL;
276+
}
270277

271-
@Override
278+
public void setNotifyURL(String notifyURL) {
279+
this.notifyURL = notifyURL;
280+
}
281+
282+
public String getTradeType() {
283+
return tradeType;
284+
}
285+
286+
public void setTradeType(String tradeType) {
287+
this.tradeType = tradeType;
288+
}
289+
290+
@Override
272291
public File getTmpDirFile() {
273292
return this.tmpDirFile;
274293
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.chanjar.weixin.mp.api;
22

33
import me.chanjar.weixin.common.exception.WxErrorException;
4-
import me.chanjar.weixin.mp.bean.pay.WxPayJsSDKCallback;
54
import me.chanjar.weixin.mp.bean.pay.request.WxEntPayRequest;
65
import me.chanjar.weixin.mp.bean.pay.request.WxPayRefundRequest;
76
import me.chanjar.weixin.mp.bean.pay.request.WxPaySendRedpackRequest;
@@ -107,15 +106,82 @@ public interface WxMpPayService {
107106
* 读取支付结果通知
108107
* 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
109108
*/
110-
WxPayJsSDKCallback getJSSDKCallbackData(String xmlData) throws WxErrorException;
109+
WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxErrorException;
110+
111+
/**
112+
* 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
113+
*
114+
* @param xmlbean Bean需要标记有XML注解,默认使用配置中的PartnerKey进行签名
115+
* @since 2.5.0
116+
* @return 签名字符串
117+
* @see #createSign(Map, String)
118+
*/
119+
String createSign(Object xmlbean);
120+
121+
/**
122+
* 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
123+
* @param xmlbean Bean需要标记有XML注解
124+
* @param signKey 签名Key
125+
* @return 签名字符串
126+
* @see #createSign(Map, String)
127+
*/
128+
String createSign(Object xmlbean, String signKey);
129+
130+
/**
131+
* 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
132+
* @param prams 参数信息,默认使用配置中的PartnerKey进行签名
133+
* @param signKey 签名Key
134+
* @return 签名字符串
135+
* @see #createSign(Map, String)
136+
*/
137+
String createSign(Map<String, String> prams);
138+
139+
140+
/**
141+
* 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
142+
* @param prams 参数信息
143+
* @param signKey 签名Key
144+
* @return 签名字符串
145+
*/
146+
String createSign(Map<String, String> prams, String signKey);
111147

148+
149+
112150
/**
113-
* <pre>
114-
* 计算Map键值对是否和签名相符,
115-
* 按照字段名的 ASCII 码从小到大排序(字典序)后,使用 URL 键值对的 格式(即 key1=value1&key2=value2...)拼接成字符串
116-
* </pre>
151+
* 校验签名是否正确,默认使用配置中的PartnerKey进行签名
152+
* @param xmlbean Bean需要标记有XML注解
153+
* @return true - 签名校验成功,false - 签名校验失败
154+
* @see #checkSign(Map, String)
155+
*/
156+
boolean checkSign(Object xmlbean);
157+
158+
/**
159+
* 校验签名是否正确
160+
* @param xmlbean Bean需要标记有XML注解
161+
* @param signKey 校验的签名Key
162+
* @return true - 签名校验成功,false - 签名校验失败
163+
* @see #checkSign(Map, String)
164+
*/
165+
boolean checkSign(Object xmlbean, String signKey);
166+
167+
/**
168+
* 校验签名是否正确,默认使用配置中的PartnerKey进行签名
169+
* @param prams 需要校验的参数Map
170+
* @return true - 签名校验成功,false - 签名校验失败
171+
* @see #checkSign(Map, String)
172+
*/
173+
boolean checkSign(Map<String, String> prams);
174+
175+
/**
176+
* 校验签名是否正确
177+
* @param prams 需要校验的参数Map
178+
* @param signKey 校验的签名Key
179+
* @return true - 签名校验成功,false - 签名校验失败
180+
* @see #checkSign(Map, String)
117181
*/
118-
boolean checkJSSDKCallbackDataSignature(Map<String, String> kvm, String signature);
182+
boolean checkSign(Map<String, String> prams, String signKey);
183+
184+
119185

120186
/**
121187
* 发送微信红包给个人用户

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import me.chanjar.weixin.mp.api.WxMpMenuService;
66
import me.chanjar.weixin.mp.api.WxMpService;
77
import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult;
8-
import me.chanjar.weixin.mp.bean.menu.WxMpSelfMenuInfo;
98
import org.slf4j.Logger;
109
import org.slf4j.LoggerFactory;
1110

0 commit comments

Comments
 (0)