Search in sources :

Example 1 with AlipayConfigDo

use of com.albedo.java.modules.tool.domain.AlipayConfigDo in project albedo by somowhere.

the class AliPayResource method toPayAsPc.

@LogOperate("支付宝PC网页支付")
@Operation(summary = "PC网页支付")
@PostMapping(value = "/toPayAsPC")
public ResponseEntity<String> toPayAsPc(@Validated @RequestBody TradeVo trade) throws Exception {
    AlipayConfigDo aliPay = alipayService.find();
    trade.setOutTradeNo(alipayUtils.getOrderCode());
    String payUrl = alipayService.toPayAsPc(aliPay, trade);
    return ResponseEntity.ok(payUrl);
}
Also used : AlipayConfigDo(com.albedo.java.modules.tool.domain.AlipayConfigDo) LogOperate(com.albedo.java.common.log.annotation.LogOperate) Operation(io.swagger.v3.oas.annotations.Operation)

Example 2 with AlipayConfigDo

use of com.albedo.java.modules.tool.domain.AlipayConfigDo in project albedo by somowhere.

the class AliPayResource method toPayAsWeb.

@LogOperate("支付宝手机网页支付")
@Operation(summary = "手机网页支付")
@PostMapping(value = "/toPayAsWeb")
public ResponseEntity<String> toPayAsWeb(@Validated @RequestBody TradeVo trade) throws Exception {
    AlipayConfigDo alipay = alipayService.find();
    trade.setOutTradeNo(alipayUtils.getOrderCode());
    String payUrl = alipayService.toPayAsWeb(alipay, trade);
    return ResponseEntity.ok(payUrl);
}
Also used : AlipayConfigDo(com.albedo.java.modules.tool.domain.AlipayConfigDo) LogOperate(com.albedo.java.common.log.annotation.LogOperate) Operation(io.swagger.v3.oas.annotations.Operation)

Example 3 with AlipayConfigDo

use of com.albedo.java.modules.tool.domain.AlipayConfigDo in project albedo by somowhere.

the class AliPayResource method notify.

@RequestMapping("/notify")
@AnonymousAccess
@SuppressWarnings("all")
@Operation(hidden = true, summary = "支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理")
public ResponseEntity<Object> notify(HttpServletRequest request) {
    AlipayConfigDo alipay = alipayService.find();
    Map<String, String[]> parameterMap = request.getParameterMap();
    // 内容验签,防止黑客篡改参数
    if (alipayUtils.rsaCheck(request, alipay)) {
        // 交易状态
        String tradeStatus = new String(request.getParameter("trade_status").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        // 商户订单号
        String outTradeNo = new String(request.getParameter("out_trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        // 支付宝交易号
        String tradeNo = new String(request.getParameter("trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        // 付款金额
        String totalAmount = new String(request.getParameter("total_amount").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        // 验证
        if (tradeStatus.equals(AliPayStatusEnum.SUCCESS.getValue()) || tradeStatus.equals(AliPayStatusEnum.FINISHED.getValue())) {
        // 验证通过后应该根据业务需要处理订单
        }
        return new ResponseEntity<>(HttpStatus.OK);
    }
    return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) AlipayConfigDo(com.albedo.java.modules.tool.domain.AlipayConfigDo) AnonymousAccess(com.albedo.java.common.core.annotation.AnonymousAccess) Operation(io.swagger.v3.oas.annotations.Operation)

Example 4 with AlipayConfigDo

use of com.albedo.java.modules.tool.domain.AlipayConfigDo in project albedo by somowhere.

the class AliPayResource method returnPage.

@GetMapping("/return")
@AnonymousAccess
@Operation(hidden = true, summary = "支付之后跳转的链接")
public ResponseEntity<String> returnPage(HttpServletRequest request, HttpServletResponse response) {
    AlipayConfigDo alipay = alipayService.find();
    response.setContentType("text/html;charset=" + alipay.getCharset());
    // 内容验签,防止黑客篡改参数
    if (alipayUtils.rsaCheck(request, alipay)) {
        // 商户订单号
        String outTradeNo = new String(request.getParameter("out_trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        // 支付宝交易号
        String tradeNo = new String(request.getParameter("trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        System.out.println("商户订单号" + outTradeNo + "  " + "第三方交易号" + tradeNo);
        // 根据业务需要返回数据,这里统一返回OK
        return new ResponseEntity<>("payment successful", HttpStatus.OK);
    } else {
        // 根据业务需要返回数据
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) AlipayConfigDo(com.albedo.java.modules.tool.domain.AlipayConfigDo) AnonymousAccess(com.albedo.java.common.core.annotation.AnonymousAccess) Operation(io.swagger.v3.oas.annotations.Operation)

Aggregations

AlipayConfigDo (com.albedo.java.modules.tool.domain.AlipayConfigDo)4 Operation (io.swagger.v3.oas.annotations.Operation)4 AnonymousAccess (com.albedo.java.common.core.annotation.AnonymousAccess)2 LogOperate (com.albedo.java.common.log.annotation.LogOperate)2 ResponseEntity (org.springframework.http.ResponseEntity)2