From 5e017f5db78215358693f13e2f88679f637e790b Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 12 May 2023 10:38:09 +0800 Subject: [PATCH] 支付设置 --- src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 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..b490620 100644 --- a/src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java +++ b/src/main/java/cc/mrbird/febs/pay/controller/PayCallBackController.java @@ -1,16 +1,19 @@ package cc.mrbird.febs.pay.controller; -import cc.mrbird.febs.common.entity.FebsResponse; import cc.mrbird.febs.pay.properties.AliPayProperties; +import cc.mrbird.febs.pay.service.AliIPayService; 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 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -28,10 +31,15 @@ public class PayCallBackController { @Autowired - private IPayService payService; + private AliIPayService payService; @Resource private AliPayProperties aliPayProperties; + + private WxPayService wxPayService = new com.github.binarywang.wxpay.service.impl.WxPayServiceImpl(); + + @Autowired + private IPayService wechatPayService; @RequestMapping("/aliCallBack") public String aliPayCallBack(HttpServletRequest request){ @@ -42,7 +50,7 @@ try { verifyResult = AlipaySignature.verifyV1(params, aliPayProperties.getPublicKey(), "UTF-8", "RSA2"); } catch (AlipayApiException e) { - log.info("验证失败=="); + log.info("=验证失败=:{}", params); return "failure"; } @@ -51,12 +59,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