From b2a8335cef9c9d85aeca808d500e85b92032585d Mon Sep 17 00:00:00 2001
From: Hentua <wangdoubleone@gmail.com>
Date: Fri, 07 Apr 2023 14:55:51 +0800
Subject: [PATCH] 添加微信支付
---
src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java b/src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java
index ea26df0..57abbe5 100644
--- a/src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java
+++ b/src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java
@@ -2,17 +2,20 @@
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.pay.properties.AliPayProperties;
+import cc.mrbird.febs.pay.service.IAliPayService;
import cc.mrbird.febs.pay.service.IPayService;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
+import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.WxPayService;
import com.ijpay.alipay.AliPayApi;
import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.service.WxService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -28,10 +31,16 @@
public class PayCallBackController {
@Autowired
- private IPayService payService;
+ private IAliPayService payService;
+
+ @Autowired
+ private IPayService wechatPayService;
@Resource
private AliPayProperties aliPayProperties;
+
+ @Autowired
+ private WxPayService wxPayService;
@RequestMapping("/aliCallBack")
public String aliPayCallBack(HttpServletRequest request){
@@ -42,7 +51,7 @@
try {
verifyResult = AlipaySignature.verifyV1(params, aliPayProperties.getPublicKey(), "UTF-8", "RSA2");
} catch (AlipayApiException e) {
- log.info("验证失败==");
+ log.info("=验证失败=:{}", params);
return "failure";
}
@@ -51,12 +60,21 @@
payService.aliCallback(params);
return "success";
} else {
- log.info("支付失败");
+ log.info("支付失败:{}", params);
return "failure";
}
} else {
- log.info("验证失败");
+ log.info("验证失败:{}", params);
return "failure";
}
}
+
+ @PostMapping(value = "/wxPayCallBack")
+ public String wxPayCallBack(@RequestBody String xmlData) throws WxPayException {
+ log.info("=======微信回调:{}========", xmlData);
+ WxPayOrderNotifyResult notifyResult = this.wxPayService.parseOrderNotifyResult(xmlData);
+
+ wechatPayService.payCallback(notifyResult.toMap());
+ return WxPayNotifyResponse.success("成功");
+ }
}
--
Gitblit v1.9.1