|
|
@@ -34,6 +34,9 @@ import cn.lili.modules.payment.kit.enums.PaymentMethodEnum;
|
|
|
import cn.lili.modules.payment.kit.params.dto.CashierParam;
|
|
|
import cn.lili.modules.payment.kit.plugin.wechat.enums.WechatDomain;
|
|
|
import cn.lili.modules.payment.kit.plugin.wechat.model.*;
|
|
|
+import cn.lili.modules.payment.kit.plugin.yeepay.common.YeePayConst;
|
|
|
+import cn.lili.modules.payment.kit.plugin.yeepay.entity.InitOrderDto;
|
|
|
+import cn.lili.modules.payment.kit.plugin.yeepay.service.YeePayService;
|
|
|
import cn.lili.modules.payment.service.PaymentService;
|
|
|
import cn.lili.modules.payment.service.RefundLogService;
|
|
|
import cn.lili.modules.system.entity.dos.Setting;
|
|
|
@@ -42,6 +45,7 @@ import cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem;
|
|
|
import cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting;
|
|
|
import cn.lili.modules.system.entity.enums.SettingEnum;
|
|
|
import cn.lili.modules.system.service.SettingService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -56,6 +60,8 @@ import java.util.Date;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
+import static cn.lili.modules.payment.kit.plugin.yeepay.service.YeePayService.PREFIX_PAYMENT;
|
|
|
+
|
|
|
/**
|
|
|
* 微信支付
|
|
|
*
|
|
|
@@ -88,6 +94,12 @@ public class WechatPlugin implements Payment {
|
|
|
@Autowired
|
|
|
private ConnectService connectService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private YeePayService yeePayService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YeePayConst yeePayConst;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public ResultMessage<Object> h5pay(HttpServletRequest request, HttpServletResponse response1, PayParam payParam) {
|
|
|
@@ -279,66 +291,160 @@ public class WechatPlugin implements Payment {
|
|
|
@Override
|
|
|
public ResultMessage<Object> nativePay(HttpServletRequest request, PayParam payParam) {
|
|
|
|
|
|
- try {
|
|
|
-
|
|
|
+// try {
|
|
|
+//
|
|
|
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
|
|
-
|
|
|
- //支付金额
|
|
|
- Integer fen = CurrencyUtil.fen(cashierParam.getPrice());
|
|
|
- //第三方付款订单
|
|
|
+//
|
|
|
+// //支付金额
|
|
|
+// Integer fen = CurrencyUtil.fen(cashierParam.getPrice());
|
|
|
+// //第三方付款订单
|
|
|
String outOrderNo = SnowFlake.getIdStr();
|
|
|
- //过期时间
|
|
|
- String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
|
|
|
-
|
|
|
- String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
|
|
|
-
|
|
|
- WechatPaymentSetting setting = wechatPaymentSetting();
|
|
|
- UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
|
|
|
- .setAppid(setting.getAppId())
|
|
|
- .setMchid(setting.getMchId())
|
|
|
- .setDescription(cashierParam.getDetail())
|
|
|
- .setOut_trade_no(outOrderNo)
|
|
|
- .setTime_expire(timeExpire)
|
|
|
- //回传参数
|
|
|
- .setAttach(attach)
|
|
|
- .setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
|
|
- .setAmount(new Amount().setTotal(fen));
|
|
|
-
|
|
|
- log.info("统一下单参数 {}", JSONUtil.toJsonStr(unifiedOrderModel));
|
|
|
- PaymentHttpResponse response = WechatApi.v3(
|
|
|
- RequestMethodEnums.POST,
|
|
|
- WechatDomain.CHINA.toString(),
|
|
|
- cn.lili.modules.payment.kit.plugin.wechat.enums.WechatApi.NATIVE_PAY.toString(),
|
|
|
- setting.getMchId(),
|
|
|
- setting.getSerialNumber(),
|
|
|
- null,
|
|
|
- setting.getApiclient_key(),
|
|
|
- JSONUtil.toJsonStr(unifiedOrderModel)
|
|
|
- );
|
|
|
- log.info("统一下单响应 {}", response);
|
|
|
- //根据证书序列号查询对应的证书来验证签名结果
|
|
|
- boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
|
|
- log.info("verifySignature: {}", verifySignature);
|
|
|
-
|
|
|
- if (verifySignature) {
|
|
|
- return ResultUtil.data(new JSONObject(response.getBody()).getStr("code_url"));
|
|
|
- } else {
|
|
|
- log.error("微信支付参数验证错误,请及时处理");
|
|
|
- throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
- }
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("支付异常", e);
|
|
|
- throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("支付异常", e);
|
|
|
- throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
- }
|
|
|
+// //过期时间
|
|
|
+// String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
|
|
|
+//
|
|
|
+// String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
|
|
|
+//
|
|
|
+// WechatPaymentSetting setting = wechatPaymentSetting();
|
|
|
+// UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
|
|
|
+// .setAppid(setting.getAppId())
|
|
|
+// .setMchid(setting.getMchId())
|
|
|
+// .setDescription(cashierParam.getDetail())
|
|
|
+// .setOut_trade_no(outOrderNo)
|
|
|
+// .setTime_expire(timeExpire)
|
|
|
+// //回传参数
|
|
|
+// .setAttach(attach)
|
|
|
+// .setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
|
|
+// .setAmount(new Amount().setTotal(fen));
|
|
|
+//
|
|
|
+// log.info("统一下单参数 {}", JSONUtil.toJsonStr(unifiedOrderModel));
|
|
|
+// PaymentHttpResponse response = WechatApi.v3(
|
|
|
+// RequestMethodEnums.POST,
|
|
|
+// WechatDomain.CHINA.toString(),
|
|
|
+// cn.lili.modules.payment.kit.plugin.wechat.enums.WechatApi.NATIVE_PAY.toString(),
|
|
|
+// setting.getMchId(),
|
|
|
+// setting.getSerialNumber(),
|
|
|
+// null,
|
|
|
+// setting.getApiclient_key(),
|
|
|
+// JSONUtil.toJsonStr(unifiedOrderModel)
|
|
|
+// );
|
|
|
+// log.info("统一下单响应 {}", response);
|
|
|
+// //根据证书序列号查询对应的证书来验证签名结果
|
|
|
+// boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
|
|
+// log.info("verifySignature: {}", verifySignature);
|
|
|
+//
|
|
|
+// if (verifySignature) {
|
|
|
+// return ResultUtil.data(new JSONObject(response.getBody()).getStr("code_url"));
|
|
|
+// } else {
|
|
|
+// log.error("微信支付参数验证错误,请及时处理");
|
|
|
+// throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
+// }
|
|
|
+// } catch (ServiceException e) {
|
|
|
+// log.error("支付异常", e);
|
|
|
+// throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("支付异常", e);
|
|
|
+// throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
+// }
|
|
|
+
|
|
|
+ cache.put(PREFIX_PAYMENT+outOrderNo,URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8));
|
|
|
+
|
|
|
+ InitOrderDto initOrderDto = InitOrderDto.builder()
|
|
|
+ .channel("WECHAT")
|
|
|
+ .goodsName(cashierParam.getTitle())
|
|
|
+ .orderAmount(cashierParam.getPrice())
|
|
|
+ .orderId(outOrderNo)
|
|
|
+ .payWay("USER_SCAN")
|
|
|
+ .notifyUrl(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
|
|
+ .scene("OFFLINE")
|
|
|
+ .userIp("127.0.0.1")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ return ResultUtil.data(yeePayService.initOrder(initOrderDto));
|
|
|
}
|
|
|
+// 这里为微信原生,现已替换易宝代付
|
|
|
+// @Override
|
|
|
+// public ResultMessage<Object> mpPay(HttpServletRequest request, PayParam payParam) {
|
|
|
+//
|
|
|
+// try {
|
|
|
+// LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+// queryWrapper.eq(Connect::getUserId, UserContext.getCurrentUser().getId())
|
|
|
+// .eq(Connect::getUnionType, ConnectEnum.WECHAT_MP_OPEN_ID.name());
|
|
|
+// Connect connect = connectService.getOne(queryWrapper);
|
|
|
+// if (connect == null) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+//
|
|
|
+// Payer payer = new Payer();
|
|
|
+// payer.setOpenid(connect.getUnionId());
|
|
|
+//
|
|
|
+// CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
|
|
+//
|
|
|
+// //支付金额
|
|
|
+// Integer fen = CurrencyUtil.fen(cashierParam.getPrice());
|
|
|
+// //第三方付款订单
|
|
|
+// String outOrderNo = SnowFlake.getIdStr();
|
|
|
+// //过期时间
|
|
|
+// String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
|
|
|
+//
|
|
|
+// //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法
|
|
|
+// //如果有2开需求,这里需要调整,修改这个appid的获取途径即可
|
|
|
+// WechatConnectSettingItem wechatConnectSettingItem = getWechatMPSetting();
|
|
|
+// String appid = null;
|
|
|
+// if (wechatConnectSettingItem != null) {
|
|
|
+// appid = getWechatMPSetting().getAppId();
|
|
|
+// }
|
|
|
+//
|
|
|
+// String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
|
|
|
+//
|
|
|
+// WechatPaymentSetting setting = wechatPaymentSetting();
|
|
|
+// UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
|
|
|
+// .setAppid(appid)
|
|
|
+// .setMchid(setting.getMchId())
|
|
|
+// .setDescription(cashierParam.getDetail())
|
|
|
+// .setOut_trade_no(outOrderNo)
|
|
|
+// .setTime_expire(timeExpire)
|
|
|
+// .setAttach(attach)
|
|
|
+// .setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
|
|
+// .setAmount(new Amount().setTotal(fen))
|
|
|
+// .setPayer(payer);
|
|
|
+//
|
|
|
+// log.info("统一下单参数 {}", JSONUtil.toJsonStr(unifiedOrderModel));
|
|
|
+// PaymentHttpResponse response = WechatApi.v3(
|
|
|
+// RequestMethodEnums.POST,
|
|
|
+// WechatDomain.CHINA.toString(),
|
|
|
+// cn.lili.modules.payment.kit.plugin.wechat.enums.WechatApi.JS_API_PAY.toString(),
|
|
|
+// setting.getMchId(),
|
|
|
+// setting.getSerialNumber(),
|
|
|
+// null,
|
|
|
+// setting.getApiclient_key(),
|
|
|
+// JSONUtil.toJsonStr(unifiedOrderModel)
|
|
|
+// );
|
|
|
+// //根据证书序列号查询对应的证书来验证签名结果
|
|
|
+// boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
|
|
+// log.info("verifySignature: {}", verifySignature);
|
|
|
+// log.info("统一下单响应 {}", response);
|
|
|
+//
|
|
|
+// if (verifySignature) {
|
|
|
+// String body = response.getBody();
|
|
|
+// JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
+// String prepayId = jsonObject.getStr("prepay_id");
|
|
|
+// Map<String, String> map = WxPayKit.jsApiCreateSign(appid, prepayId, setting.getApiclient_key());
|
|
|
+// log.info("唤起支付参数:{}", map);
|
|
|
+//
|
|
|
+// return ResultUtil.data(map);
|
|
|
+// }
|
|
|
+// log.error("微信支付参数验证错误,请及时处理");
|
|
|
+// throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("支付异常", e);
|
|
|
+// throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
- public ResultMessage<Object> mpPay(HttpServletRequest request, PayParam payParam) {
|
|
|
+ public ResultMessage<Object> mpPay(HttpServletRequest request, PayParam payParam) {
|
|
|
|
|
|
- try {
|
|
|
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(Connect::getUserId, UserContext.getCurrentUser().getId())
|
|
|
.eq(Connect::getUnionType, ConnectEnum.WECHAT_MP_OPEN_ID.name());
|
|
|
@@ -347,19 +453,22 @@ public class WechatPlugin implements Payment {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- Payer payer = new Payer();
|
|
|
- payer.setOpenid(connect.getUnionId());
|
|
|
|
|
|
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
|
|
|
|
|
- //支付金额
|
|
|
- Integer fen = CurrencyUtil.fen(cashierParam.getPrice());
|
|
|
+
|
|
|
//第三方付款订单
|
|
|
- String outOrderNo = SnowFlake.getIdStr();
|
|
|
- //过期时间
|
|
|
- String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
|
|
|
|
|
|
- //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法
|
|
|
+ String outOrderNo = SnowFlake.getIdStr();
|
|
|
+ String timeExpire = null;
|
|
|
+ //过期时间
|
|
|
+ try {
|
|
|
+ timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("支付过期时间异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法
|
|
|
//如果有2开需求,这里需要调整,修改这个appid的获取途径即可
|
|
|
WechatConnectSettingItem wechatConnectSettingItem = getWechatMPSetting();
|
|
|
String appid = null;
|
|
|
@@ -367,52 +476,26 @@ public class WechatPlugin implements Payment {
|
|
|
appid = getWechatMPSetting().getAppId();
|
|
|
}
|
|
|
|
|
|
- String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
|
|
|
-
|
|
|
- WechatPaymentSetting setting = wechatPaymentSetting();
|
|
|
- UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
|
|
|
- .setAppid(appid)
|
|
|
- .setMchid(setting.getMchId())
|
|
|
- .setDescription(cashierParam.getDetail())
|
|
|
- .setOut_trade_no(outOrderNo)
|
|
|
- .setTime_expire(timeExpire)
|
|
|
- .setAttach(attach)
|
|
|
- .setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
|
|
- .setAmount(new Amount().setTotal(fen))
|
|
|
- .setPayer(payer);
|
|
|
-
|
|
|
- log.info("统一下单参数 {}", JSONUtil.toJsonStr(unifiedOrderModel));
|
|
|
- PaymentHttpResponse response = WechatApi.v3(
|
|
|
- RequestMethodEnums.POST,
|
|
|
- WechatDomain.CHINA.toString(),
|
|
|
- cn.lili.modules.payment.kit.plugin.wechat.enums.WechatApi.JS_API_PAY.toString(),
|
|
|
- setting.getMchId(),
|
|
|
- setting.getSerialNumber(),
|
|
|
- null,
|
|
|
- setting.getApiclient_key(),
|
|
|
- JSONUtil.toJsonStr(unifiedOrderModel)
|
|
|
- );
|
|
|
- //根据证书序列号查询对应的证书来验证签名结果
|
|
|
- boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
|
|
- log.info("verifySignature: {}", verifySignature);
|
|
|
- log.info("统一下单响应 {}", response);
|
|
|
-
|
|
|
- if (verifySignature) {
|
|
|
- String body = response.getBody();
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
- String prepayId = jsonObject.getStr("prepay_id");
|
|
|
- Map<String, String> map = WxPayKit.jsApiCreateSign(appid, prepayId, setting.getApiclient_key());
|
|
|
- log.info("唤起支付参数:{}", map);
|
|
|
+ cache.put(PREFIX_PAYMENT+outOrderNo, URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8));
|
|
|
+
|
|
|
+ com.alibaba.fastjson.JSONObject res = yeePayService.initOrder(
|
|
|
+ InitOrderDto.builder()
|
|
|
+ .appId(appid)
|
|
|
+ .channel("WECHAT")
|
|
|
+ .expiredTime(timeExpire)
|
|
|
+ .goodsName(cashierParam.getTitle())
|
|
|
+ .notifyUrl(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
|
|
+ .orderAmount(cashierParam.getPrice())
|
|
|
+ .scene("ONLINE")
|
|
|
+ .orderId(outOrderNo)
|
|
|
+ .payWay("MINI_PROGRAM")
|
|
|
+ .userId(connect.getUnionId())
|
|
|
+ .userIp("127.0.0.1")
|
|
|
+ .build()
|
|
|
|
|
|
- return ResultUtil.data(map);
|
|
|
- }
|
|
|
- log.error("微信支付参数验证错误,请及时处理");
|
|
|
- throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("支付异常", e);
|
|
|
- throw new ServiceException(ResultCode.PAY_ERROR);
|
|
|
- }
|
|
|
+ );
|
|
|
|
|
|
+ return ResultUtil.data(res.getJSONObject("prePayTn"));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -440,42 +523,80 @@ public class WechatPlugin implements Payment {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private void verifyNotify(HttpServletRequest request) throws Exception {
|
|
|
-
|
|
|
- String timestamp = request.getHeader("Wechatpay-Timestamp");
|
|
|
- String nonce = request.getHeader("Wechatpay-Nonce");
|
|
|
- String serialNo = request.getHeader("Wechatpay-Serial");
|
|
|
- String signature = request.getHeader("Wechatpay-Signature");
|
|
|
-
|
|
|
- log.info("timestamp:{} nonce:{} serialNo:{} signature:{}", timestamp, nonce, serialNo, signature);
|
|
|
- String result = HttpKit.readData(request);
|
|
|
- log.info("微信支付通知密文 {}", result);
|
|
|
-
|
|
|
- WechatPaymentSetting setting = wechatPaymentSetting();
|
|
|
- //校验服务器端响应¬
|
|
|
- String plainText = WxPayKit.verifyNotify(serialNo, result, signature, nonce, timestamp,
|
|
|
- setting.getApiKey3(), Objects.requireNonNull(getPlatformCert()));
|
|
|
-
|
|
|
- log.info("微信支付通知明文 {}", plainText);
|
|
|
-
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(plainText);
|
|
|
-
|
|
|
- String payParamStr = jsonObject.getStr("attach");
|
|
|
+ System.out.println("微信-易宝支付回调: map"+ JSON.toJSONString(request.getParameterMap()));
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = yeePayService.deCodeNotifyData(request.getParameterMap().get("cipherText")[0]);
|
|
|
+ log.info("微信解密回调密文:"+jsonObject.toJSONString());
|
|
|
+
|
|
|
+ /*
|
|
|
+ * {
|
|
|
+ "channelOrderId":"4200001146202107231811930975",
|
|
|
+ "orderId":"1418392045155778560",
|
|
|
+ "bankOrderId":"5937679445210723",
|
|
|
+ "paySuccessDate":"2021-07-23 10:06:38",
|
|
|
+ "channel":"WECHAT",
|
|
|
+ "payWay":"USER_SCAN",
|
|
|
+ "uniqueOrderNo":"1013202107230000002449173814",
|
|
|
+ "orderAmount":"0.01",
|
|
|
+ "payAmount":"0.01",
|
|
|
+ "payerInfo":"{\"bankCardNo\":\"\",\"bankId\":\"CFT\",\"cardType\":\"CFT\",\"mobilePhoneNo\":\"\",\"userID\":\"o19581K7Nz5lUwsqaT10yTqOe1MI\"}",
|
|
|
+ "realPayAmount":"0.01",
|
|
|
+ "parentMerchantNo":"10086062555",
|
|
|
+ "merchantNo":"10086062555",
|
|
|
+ "status":"SUCCESS"
|
|
|
+ }
|
|
|
+ * */
|
|
|
+
|
|
|
+
|
|
|
+ String payParamStr = cache.get(PREFIX_PAYMENT+jsonObject.getString("orderId"));
|
|
|
String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8);
|
|
|
PayParam payParam = JSONUtil.toBean(payParamJson, PayParam.class);
|
|
|
|
|
|
|
|
|
- String tradeNo = jsonObject.getStr("transaction_id");
|
|
|
- Double totalAmount = CurrencyUtil.reversalFen(jsonObject.getJSONObject("amount").getDouble("total"));
|
|
|
-
|
|
|
PaymentSuccessParams paymentSuccessParams = new PaymentSuccessParams(
|
|
|
PaymentMethodEnum.WECHAT.name(),
|
|
|
- tradeNo,
|
|
|
- totalAmount,
|
|
|
+ jsonObject.getString("orderId"),
|
|
|
+ jsonObject.getDouble("orderAmount"),
|
|
|
payParam
|
|
|
);
|
|
|
|
|
|
paymentService.success(paymentSuccessParams);
|
|
|
- log.info("微信支付回调:支付成功{}", plainText);
|
|
|
+
|
|
|
+
|
|
|
+// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
|
|
+// String nonce = request.getHeader("Wechatpay-Nonce");
|
|
|
+// String serialNo = request.getHeader("Wechatpay-Serial");
|
|
|
+// String signature = request.getHeader("Wechatpay-Signature");
|
|
|
+//
|
|
|
+// log.info("timestamp:{} nonce:{} serialNo:{} signature:{}", timestamp, nonce, serialNo, signature);
|
|
|
+// String result = HttpKit.readData(request);
|
|
|
+// log.info("微信支付通知密文 {}", result);
|
|
|
+//
|
|
|
+// WechatPaymentSetting setting = wechatPaymentSetting();
|
|
|
+// //校验服务器端响应¬
|
|
|
+// String plainText = WxPayKit.verifyNotify(serialNo, result, signature, nonce, timestamp,
|
|
|
+// setting.getApiKey3(), Objects.requireNonNull(getPlatformCert()));
|
|
|
+//
|
|
|
+// log.info("微信支付通知明文 {}", plainText);
|
|
|
+//
|
|
|
+// JSONObject jsonObject = JSONUtil.parseObj(plainText);
|
|
|
+//
|
|
|
+// String payParamStr = jsonObject.getStr("attach");
|
|
|
+// String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8);
|
|
|
+// PayParam payParam = JSONUtil.toBean(payParamJson, PayParam.class);
|
|
|
+//
|
|
|
+//
|
|
|
+// String tradeNo = jsonObject.getStr("transaction_id");
|
|
|
+// Double totalAmount = CurrencyUtil.reversalFen(jsonObject.getJSONObject("amount").getDouble("total"));
|
|
|
+//
|
|
|
+// PaymentSuccessParams paymentSuccessParams = new PaymentSuccessParams(
|
|
|
+// PaymentMethodEnum.WECHAT.name(),
|
|
|
+// tradeNo,
|
|
|
+// totalAmount,
|
|
|
+// payParam
|
|
|
+// );
|
|
|
+//
|
|
|
+// paymentService.success(paymentSuccessParams);
|
|
|
+// log.info("微信支付回调:支付成功{}", plainText);
|
|
|
}
|
|
|
|
|
|
@Override
|