初始化
parent
8db9be5b9e
commit
289d7c0993
|
@ -10,6 +10,8 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class AliPay {
|
public class AliPay {
|
||||||
|
//路径
|
||||||
|
private String returnUrl;
|
||||||
//订单编号
|
//订单编号
|
||||||
private String traceNo;
|
private String traceNo;
|
||||||
//商品金额
|
//商品金额
|
||||||
|
|
|
@ -37,18 +37,15 @@ public class AliPayController {
|
||||||
private static final String CHARSET ="utf-8";
|
private static final String CHARSET ="utf-8";
|
||||||
private static final String SIGN_TYPE ="RSA2";
|
private static final String SIGN_TYPE ="RSA2";
|
||||||
|
|
||||||
@GetMapping("/pay") // 前端路径参数格式?subject=xxx&traceNo=xxx&totalAmount=xxx
|
@PostMapping("/pay")
|
||||||
public void pay(@RequestParam(name = "traceNo") String traceNo, HttpServletResponse httpResponse) throws Exception {
|
@ResponseBody
|
||||||
AliPay aliPay = new AliPay();
|
public void pay(@RequestBody AliPay aliPay, HttpServletResponse httpResponse) throws Exception {
|
||||||
aliPay.setTraceNo(traceNo);
|
|
||||||
aliPay.setSubject(traceNo);
|
|
||||||
aliPay.setTotalAmount(1);
|
|
||||||
AlipayClient alipayClient = new DefaultAlipayClient(GATEWAY_URL, aliPayConfig.getAppId(),
|
AlipayClient alipayClient = new DefaultAlipayClient(GATEWAY_URL, aliPayConfig.getAppId(),
|
||||||
aliPayConfig.getAppPrivateKey(), FORMAT, CHARSET, aliPayConfig.getAlipayPublicKey(), SIGN_TYPE);
|
aliPayConfig.getAppPrivateKey(), FORMAT, CHARSET, aliPayConfig.getAlipayPublicKey(), SIGN_TYPE);
|
||||||
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
||||||
request.setNotifyUrl(aliPayConfig.getNotifyUrl());
|
request.setNotifyUrl(aliPayConfig.getNotifyUrl());
|
||||||
request.setReturnUrl(aliPayConfig.getReturnUrl());
|
request.setReturnUrl(aliPay.getReturnUrl());
|
||||||
request.setBizContent("{\"out_trade_no\":\"" + traceNo + "\","
|
request.setBizContent("{\"out_trade_no\":\"" + aliPay.getTraceNo() + "\","
|
||||||
+ "\"total_amount\":\"" + aliPay.getTotalAmount() + "\","
|
+ "\"total_amount\":\"" + aliPay.getTotalAmount() + "\","
|
||||||
+ "\"subject\":\"" + aliPay.getSubject() + "\","
|
+ "\"subject\":\"" + aliPay.getSubject() + "\","
|
||||||
+ "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
|
+ "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
|
||||||
|
|
Loading…
Reference in New Issue