Skip to content

Commit d7a5607

Browse files
committed
🐛 (兼容性警告)binarywang#2216 微信支付 APP统一下单接口v3,缺少sign参数
兼容性警告:根据微信支付v3文档,将AppResult的字段全部改为了小写,请开发者使用时注意修改 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_4.shtml
1 parent 5c71b2a commit d7a5607

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderV3Result.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,22 @@ private String getSignStr() {
9090
@Data
9191
@Accessors(chain = true)
9292
public static class AppResult implements Serializable {
93-
private static final long serialVersionUID = 5465773025172875110L;
93+
private static final long serialVersionUID = 2L;
9494

9595
private String appid;
96-
private String partnerId;
97-
private String prepayId;
96+
private String partnerid;
97+
private String prepayid;
98+
/**
99+
* 注意微信要求的字段是package,但是这是java关键字,请自行在序列化时/前端处理
100+
*/
98101
private String packageValue;
99102
private String noncestr;
100103
private String timestamp;
104+
private String sign;
101105

106+
private String getSignStr() {
107+
return String.format("%s\n%s\n%s\n%s\n", appid, timestamp, noncestr, prepayid);
108+
}
102109
}
103110

104111
public <T> T getPayInfo(TradeTypeEnum tradeType, String appId, String mchId, PrivateKey privateKey) {
@@ -116,10 +123,11 @@ public <T> T getPayInfo(TradeTypeEnum tradeType, String appId, String mchId, Pri
116123
return (T) this.h5Url;
117124
case APP:
118125
AppResult appResult = new AppResult();
119-
appResult.setAppid(appId).setPrepayId(this.prepayId).setPartnerId(mchId)
126+
appResult.setAppid(appId).setPrepayid(this.prepayId).setPartnerid(mchId)
120127
.setNoncestr(nonceStr).setTimestamp(timestamp)
121128
//暂填写固定值Sign=WXPay
122-
.setPackageValue("Sign=WXPay");
129+
.setPackageValue("Sign=WXPay")
130+
.setSign(SignUtils.sign(appResult.getSignStr(), privateKey));
123131
return (T) appResult;
124132
case NATIVE:
125133
return (T) this.codeUrl;

0 commit comments

Comments
 (0)