Skip to content

Commit

Permalink
🐛 (兼容性警告)binarywang#2216 微信支付 APP统一下单接口v3,缺少sign参数
Browse files Browse the repository at this point in the history
兼容性警告:根据微信支付v3文档,将AppResult的字段全部改为了小写,请开发者使用时注意修改
https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_4.shtml
  • Loading branch information
gadfly3173 committed Aug 9, 2021
1 parent 5c71b2a commit d7a5607
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,22 @@ private String getSignStr() {
@Data
@Accessors(chain = true)
public static class AppResult implements Serializable {
private static final long serialVersionUID = 5465773025172875110L;
private static final long serialVersionUID = 2L;

private String appid;
private String partnerId;
private String prepayId;
private String partnerid;
private String prepayid;
/**
* 注意微信要求的字段是package,但是这是java关键字,请自行在序列化时/前端处理
*/
private String packageValue;
private String noncestr;
private String timestamp;
private String sign;

private String getSignStr() {
return String.format("%s\n%s\n%s\n%s\n", appid, timestamp, noncestr, prepayid);
}
}

public <T> T getPayInfo(TradeTypeEnum tradeType, String appId, String mchId, PrivateKey privateKey) {
Expand All @@ -116,10 +123,11 @@ public <T> T getPayInfo(TradeTypeEnum tradeType, String appId, String mchId, Pri
return (T) this.h5Url;
case APP:
AppResult appResult = new AppResult();
appResult.setAppid(appId).setPrepayId(this.prepayId).setPartnerId(mchId)
appResult.setAppid(appId).setPrepayid(this.prepayId).setPartnerid(mchId)
.setNoncestr(nonceStr).setTimestamp(timestamp)
//暂填写固定值Sign=WXPay
.setPackageValue("Sign=WXPay");
.setPackageValue("Sign=WXPay")
.setSign(SignUtils.sign(appResult.getSignStr(), privateKey));
return (T) appResult;
case NATIVE:
return (T) this.codeUrl;
Expand Down

0 comments on commit d7a5607

Please sign in to comment.