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