Skip to content

Commit f379769

Browse files
SunshineTechbinarywang
authored andcommitted
binarywang#828 优化支付结果通知类的checkResult方法
该方法重写了基类中的同名方法。 return_code为SUCCESS时,如果sign为空,则该通知请求是非微信通知请求,因此抛出异常。 否则,调用基类同名方法。
1 parent 64446f3 commit f379769

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,25 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult {
284284
*/
285285
@XStreamAlias("version")
286286
private String version;
287-
287+
288+
/**
289+
* 校验返回结果签名.
290+
*
291+
* @param wxPayService the wx pay service
292+
* @param signType 签名类型
293+
* @param checkSuccess 是否同时检查结果是否成功
294+
* @throws WxPayException the wx pay exception
295+
*/
296+
@Override
297+
public void checkResult(WxPayService wxPayService, String signType, boolean checkSuccess) throws WxPayException {
298+
//防止伪造成功通知
299+
if ("SUCCESS".equals(getReturnCode()) && getSign() == null) {
300+
throw new WxPayException("伪造的通知!");
301+
}
302+
303+
super.checkResult(wxPayService, signType, checkSuccess);
304+
}
305+
288306
/**
289307
* From xml wx pay order notify result.
290308
*

0 commit comments

Comments
 (0)