9.3 李雨欣测试购买记录接口 14:38
parent
c7fcfa41de
commit
ed87ca39c5
|
@ -12,14 +12,10 @@ import javax.annotation.PostConstruct;
|
|||
@Component
|
||||
@ConfigurationProperties(prefix = "alipay")
|
||||
public class MyAliPayConfig {
|
||||
|
||||
|
||||
private String appId;
|
||||
private String appPrivateKey;
|
||||
private String alipayPublicKey;
|
||||
private String notifyUrl;
|
||||
//支付成功后的回调地址
|
||||
private String returnUrl;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
|
|
@ -5,15 +5,16 @@ import com.alipay.api.AlipayClient;
|
|||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||
|
||||
import com.muyu.market.server.config.MyAliPayConfig;
|
||||
import com.muyu.data.AliPay;
|
||||
import com.muyu.market.server.config.MyAliPayConfig;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
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 javax.annotation.Resource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
@ -26,9 +27,7 @@ public class AliPayController {
|
|||
private static final String FORMAT_JSON = "JSON";
|
||||
private static final String CHARSET_UTF8 = "UTF-8";
|
||||
private static final String SIGN_TYPE_RSA2 = "RSA2";
|
||||
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
private MyAliPayConfig myAliPayConfig;
|
||||
|
||||
@GetMapping("/pay")
|
||||
|
@ -41,7 +40,7 @@ public class AliPayController {
|
|||
aliPay.setTraceNo(UUID.randomUUID().toString().replaceAll("-",""));
|
||||
aliPay.setTotalAmount("100");
|
||||
aliPay.setSubject("笔记本华硕");
|
||||
|
||||
//=====
|
||||
request.setBizContent("{\"out_trade_no\":\"" + aliPay.getTraceNo() + "\","
|
||||
+ "\"total_amount\":\"" + aliPay.getTotalAmount() + "\","
|
||||
+ "\"subject\":\"" + aliPay.getSubject() + "\","
|
||||
|
@ -59,6 +58,7 @@ public class AliPayController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/notify") // 注意这里必须是POST接口
|
||||
public String payNotify(HttpServletRequest request) throws Exception {
|
||||
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
||||
|
@ -71,7 +71,6 @@ public class AliPayController {
|
|||
// 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");
|
||||
|
|
Loading…
Reference in New Issue