🎨 #1585 微信支付结果异步通知的解析方法增加可以自行指定signType的重载方法

This commit is contained in:
Binary Wang 2020-05-26 18:00:54 +08:00
parent edf1401dbe
commit da0ce15da6
2 changed files with 21 additions and 1 deletions

View File

@ -303,6 +303,17 @@ public interface WxPayService {
*/
WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException;
/**
* 解析支付结果通知.
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
*
* @param xmlData the xml data
* @param signType 签名类型
* @return the wx pay order notify result
* @throws WxPayException the wx pay exception
*/
WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String signType) throws WxPayException;
/**
* 解析退款结果通知
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=9

View File

@ -154,11 +154,20 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
@Override
public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException {
return this.parseOrderNotifyResult(xmlData, null);
}
@Override
public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String signType) throws WxPayException {
try {
log.debug("微信支付异步通知请求参数:{}", xmlData);
WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
if (result.getSignType() != null) {
// 如果解析的通知对象中signType有值则使用它进行验签
signType = result.getSignType();
}
log.debug("微信支付异步通知请求解析后的对象:{}", result);
result.checkResult(this, result.getSignType(), false);
result.checkResult(this, signType, false);
return result;
} catch (WxPayException e) {
throw e;