@@ -90,15 +90,22 @@ private String getSignStr() {
90
90
@ Data
91
91
@ Accessors (chain = true )
92
92
public static class AppResult implements Serializable {
93
- private static final long serialVersionUID = 5465773025172875110L ;
93
+ private static final long serialVersionUID = 2L ;
94
94
95
95
private String appid ;
96
- private String partnerId ;
97
- private String prepayId ;
96
+ private String partnerid ;
97
+ private String prepayid ;
98
+ /**
99
+ * 注意微信要求的字段是package,但是这是java关键字,请自行在序列化时/前端处理
100
+ */
98
101
private String packageValue ;
99
102
private String noncestr ;
100
103
private String timestamp ;
104
+ private String sign ;
101
105
106
+ private String getSignStr () {
107
+ return String .format ("%s\n %s\n %s\n %s\n " , appid , timestamp , noncestr , prepayid );
108
+ }
102
109
}
103
110
104
111
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
116
123
return (T ) this .h5Url ;
117
124
case APP :
118
125
AppResult appResult = new AppResult ();
119
- appResult .setAppid (appId ).setPrepayId (this .prepayId ).setPartnerId (mchId )
126
+ appResult .setAppid (appId ).setPrepayid (this .prepayId ).setPartnerid (mchId )
120
127
.setNoncestr (nonceStr ).setTimestamp (timestamp )
121
128
//暂填写固定值Sign=WXPay
122
- .setPackageValue ("Sign=WXPay" );
129
+ .setPackageValue ("Sign=WXPay" )
130
+ .setSign (SignUtils .sign (appResult .getSignStr (), privateKey ));
123
131
return (T ) appResult ;
124
132
case NATIVE :
125
133
return (T ) this .codeUrl ;
0 commit comments