Skip to content

Commit 936b40c

Browse files
committed
binarywang#555 修复微信支付服务商模式支付验证签名失败的问题
1 parent b698806 commit 936b40c

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class WxPayMpOrderResult {
2020
private String timeStamp;
2121
private String nonceStr;
2222
/**
23-
* 由于package为java保留关键字,因此改为packageValue
23+
* 由于package为java保留关键字,因此改为packageValue.
2424
*/
2525
@XStreamAlias("package")
2626
private String packageValue;

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,12 @@ public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
311311

312312
case TradeType.APP: {
313313
// APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数
314-
String appId = this.getConfig().getAppId();
315-
Map<String, String> configMap = new HashMap<>();
314+
String appId = unifiedOrderResult.getAppid();
315+
if (StringUtils.isNotEmpty(unifiedOrderResult.getSubAppId())) {
316+
appId = unifiedOrderResult.getSubAppId();
317+
}
318+
319+
Map<String, String> configMap = new HashMap<>(8);
316320
// 此map用于参与调起sdk支付的二次签名,格式全小写,timestamp只能是10位,格式固定,切勿修改
317321
String partnerId = getConfig().getMchId();
318322
configMap.put("prepayid", prepayId);
@@ -336,21 +340,20 @@ public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
336340

337341
case TradeType.JSAPI: {
338342
String signType = SignType.MD5;
343+
String appid = unifiedOrderResult.getAppid();
344+
if (StringUtils.isNotEmpty(this.getConfig().getSubAppId())) {
345+
appid = this.getConfig().getSubAppId();
346+
}
347+
339348
WxPayMpOrderResult payResult = WxPayMpOrderResult.builder()
340-
.appId(unifiedOrderResult.getAppid())
349+
.appId(appid)
341350
.timeStamp(timestamp)
342351
.nonceStr(nonceStr)
343352
.packageValue("prepay_id=" + prepayId)
344353
.signType(signType)
345354
.build();
346355

347-
payResult.setPaySign(
348-
SignUtils.createSign(
349-
payResult,
350-
signType,
351-
this.getConfig().getMchKey(),
352-
false)
353-
);
356+
payResult.setPaySign(SignUtils.createSign(payResult, signType, this.getConfig().getMchKey(), false));
354357
return (T) payResult;
355358
}
356359

@@ -534,7 +537,7 @@ private String handleGzipBill(String url, String requestStr) throws WxPayExcepti
534537
}
535538
}
536539
} catch (Exception e) {
537-
this.log.error("解析对账单文件时出错",e);
540+
this.log.error("解析对账单文件时出错", e);
538541
}
539542

540543
return null;

0 commit comments

Comments
 (0)