24
24
* 微信支付接口请求抽象实现类
25
25
* Created by Binary Wang on 2017-7-8.
26
26
* </pre>
27
+ *
27
28
* @author <a href="https://github.com/binarywang">Binary Wang</a>
28
29
*/
29
30
public abstract class WxPayServiceAbstractImpl implements WxPayService {
@@ -196,6 +197,8 @@ public Map<String, String> getPayInfo(WxPayUnifiedOrderRequest request) throws W
196
197
}
197
198
198
199
Map <String , String > payInfo = new HashMap <>();
200
+ String timestamp = String .valueOf (System .currentTimeMillis () / 1000 );
201
+ String nonceStr = String .valueOf (System .currentTimeMillis ());
199
202
if ("NATIVE" .equals (request .getTradeType ())) {
200
203
payInfo .put ("codeUrl" , unifiedOrderResult .getCodeURL ());
201
204
} else if ("APP" .equals (request .getTradeType ())) {
@@ -207,26 +210,27 @@ public Map<String, String> getPayInfo(WxPayUnifiedOrderRequest request) throws W
207
210
configMap .put ("prepayid" , prepayId );
208
211
configMap .put ("partnerid" , partnerid );
209
212
configMap .put ("package" , "Sign=WXPay" );
210
- configMap .put ("timestamp" , String . valueOf ( System . currentTimeMillis () / 1000 ) );
211
- configMap .put ("noncestr" , String . valueOf ( System . currentTimeMillis ()) );
213
+ configMap .put ("timestamp" , timestamp );
214
+ configMap .put ("noncestr" , nonceStr );
212
215
configMap .put ("appid" , appId );
213
216
// 此map用于客户端与微信服务器交互
214
217
payInfo .put ("sign" , SignUtils .createSign (configMap , this .getConfig ().getMchKey ()));
215
218
payInfo .put ("prepayId" , prepayId );
216
219
payInfo .put ("partnerId" , partnerid );
217
220
payInfo .put ("appId" , appId );
218
221
payInfo .put ("packageValue" , "Sign=WXPay" );
219
- payInfo .put ("timeStamp" , String . valueOf ( System . currentTimeMillis () / 1000 ) );
220
- payInfo .put ("nonceStr" , String . valueOf ( System . currentTimeMillis ()) );
222
+ payInfo .put ("timeStamp" , timestamp );
223
+ payInfo .put ("nonceStr" , nonceStr );
221
224
} else if ("JSAPI" .equals (request .getTradeType ())) {
222
225
payInfo .put ("appId" , unifiedOrderResult .getAppid ());
223
226
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
224
- payInfo .put ("timeStamp" , String . valueOf ( System . currentTimeMillis () / 1000 ) );
225
- payInfo .put ("nonceStr" , String . valueOf ( System . currentTimeMillis ()) );
227
+ payInfo .put ("timeStamp" , timestamp );
228
+ payInfo .put ("nonceStr" , nonceStr );
226
229
payInfo .put ("package" , "prepay_id=" + prepayId );
227
230
payInfo .put ("signType" , "MD5" );
228
231
payInfo .put ("paySign" , SignUtils .createSign (payInfo , this .getConfig ().getMchKey ()));
229
232
}
233
+
230
234
return payInfo ;
231
235
}
232
236
0 commit comments