|
@@ -55,6 +55,15 @@ public class StandardWechatPaymentProcessor implements WechatPaymentProcessor {
|
|
|
this.properties = properties;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取微信支付时间戳
|
|
|
+ *
|
|
|
+ * @return 时间戳字符串形式
|
|
|
+ */
|
|
|
+ protected String timestamp() {
|
|
|
+ return String.valueOf(System.currentTimeMillis() / 1000).substring(0, 10);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 将字符串转换成日期对象
|
|
|
*
|
|
@@ -178,16 +187,29 @@ public class StandardWechatPaymentProcessor implements WechatPaymentProcessor {
|
|
|
}
|
|
|
throw new RuntimeException("Wechat unifiedorder failed: " + message);
|
|
|
}
|
|
|
+ Map<String, String> signature = Maps.newHashMapWithExpectedSize(6);
|
|
|
WechatUnifiedOrder order = WechatUnifiedOrder.builder().mode(this.getMode()).appid(this.getAppid())
|
|
|
- .mchid(this.getMchid()).nonce(WXPayUtil.generateNonceStr()).prepayid(result.get("prepay_id"))
|
|
|
- .qrcode(result.get("code_url")).redirect(result.get("mweb_url")).channel(this.getChannel())
|
|
|
- .timestamp(String.valueOf(System.currentTimeMillis() / 1000).substring(0, 10)).build();
|
|
|
+ .mchid(this.getMchid()).order(request.getOrder()).nonce(WXPayUtil.generateNonceStr())
|
|
|
+ .prepayid(result.get("prepay_id")).qrcode(result.get("code_url")).redirect(result.get("mweb_url"))
|
|
|
+ .channel(this.getChannel()).timestamp(this.timestamp()).build();
|
|
|
if (this.getMode() == PayMode.MWEB || this.getMode() == PayMode.JSAPI) {
|
|
|
order.setAlgorithm(MessageDigestAlgorithms.MD5);
|
|
|
order.setPack("prepay_id=" + order.getPrepayid());
|
|
|
+ signature.put("appId", order.getAppid());
|
|
|
+ signature.put("nonceStr", order.getNonce());
|
|
|
+ signature.put("package", order.getPack());
|
|
|
+ signature.put("signType", order.getAlgorithm());
|
|
|
+ signature.put("timeStamp", order.getTimestamp());
|
|
|
} else {
|
|
|
order.setPack("Sign=WXPay");
|
|
|
+ signature.put("appid", order.getAppid());
|
|
|
+ signature.put("partnerid", order.getMchid());
|
|
|
+ signature.put("prepayid", order.getPrepayid());
|
|
|
+ signature.put("noncestr", order.getNonce());
|
|
|
+ signature.put("package", order.getPack());
|
|
|
+ signature.put("timestamp", order.getTimestamp());
|
|
|
}
|
|
|
+ order.setSign(this.sign(signature));
|
|
|
return order;
|
|
|
}
|
|
|
}
|