Compare commits
2 Commits
3a04eb58f9
...
5e40809b6e
Author | SHA1 | Date |
---|---|---|
|
5e40809b6e | |
|
c2e5a0611a |
10
pom.xml
10
pom.xml
|
@ -17,6 +17,16 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--引入支付宝支付 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alipay.sdk</groupId>
|
||||||
|
<artifactId>alipay-easysdk</artifactId>
|
||||||
|
<version>2.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alipay.sdk</groupId>
|
<groupId>com.alipay.sdk</groupId>
|
||||||
<artifactId>alipay-sdk-java</artifactId>
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
|
|
|
@ -6,16 +6,21 @@ import com.alipay.api.AlipayClient;
|
||||||
import com.alipay.api.DefaultAlipayClient;
|
import com.alipay.api.DefaultAlipayClient;
|
||||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||||
import com.alipay.api.response.AlipayTradePagePayResponse;
|
import com.alipay.api.response.AlipayTradePagePayResponse;
|
||||||
|
import com.alipay.easysdk.factory.Factory;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.system.domain.PaymentParam;
|
import com.muyu.common.system.domain.PaymentParam;
|
||||||
import com.muyu.config.util.SfUtil;
|
import com.muyu.config.util.SfUtil;
|
||||||
import com.muyu.config.util.StandingRes;
|
import com.muyu.config.util.StandingRes;
|
||||||
import com.muyu.system.service.SysUserService;
|
import com.muyu.system.service.SysUserService;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: wangxinyuan
|
* @Author: wangxinyuan
|
||||||
* @Date: 2024/8/25 下午3:21
|
* @Date: 2024/8/25 下午3:21
|
||||||
|
@ -77,6 +82,38 @@ public class PaymentController {
|
||||||
return Result.success(response.getBody());
|
return Result.success(response.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/notify") // 注意这里必须是POST接口
|
||||||
|
public String payNotify(HttpServletRequest request) throws Exception {
|
||||||
|
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
||||||
|
System.out.println("=========支付宝异步回调========");
|
||||||
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
Map<String, String[]> requestParams = request.getParameterMap();
|
||||||
|
for (String name : requestParams.keySet()) {
|
||||||
|
params.put(name, request.getParameter(name));
|
||||||
|
// System.out.println(name + " = " + request.getParameter(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
String tradeNo = params.get("out_trade_no");
|
||||||
|
String gmtPayment = params.get("gmt_payment");
|
||||||
|
String alipayTradeNo = params.get("trade_no");
|
||||||
|
// 支付宝验签
|
||||||
|
if (Factory.Payment.Common().verifyNotify(params)) {
|
||||||
|
// 验签通过
|
||||||
|
System.out.println("交易名称: " + params.get("subject"));
|
||||||
|
System.out.println("交易状态: " + params.get("trade_status"));
|
||||||
|
System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
||||||
|
System.out.println("商户订单号: " + params.get("out_trade_no"));
|
||||||
|
System.out.println("交易金额: " + params.get("total_amount"));
|
||||||
|
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
||||||
|
System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
||||||
|
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserService userService;
|
private SysUserService userService;
|
||||||
//TODO 充值记录添加
|
//TODO 充值记录添加
|
||||||
|
|
Loading…
Reference in New Issue