mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-11-28 01:06:42 +08:00
feat 去除支付发起时的NotReturn属性,SQL脚本更新,部署调试
This commit is contained in:
@@ -68,16 +68,16 @@
|
||||
| IJpay | 支付SDK开发包 | 项目自动管理,不需要额外处理 |
|
||||
|
||||
|
||||
## 💾 系统截图
|
||||
## 🍎 系统截图
|
||||
|
||||
### 收银台演示
|
||||

|
||||
### H5收银台演示
|
||||

|
||||
###
|
||||
### 支付演示
|
||||

|
||||
|
||||
## 🍎 路线图
|
||||
## 💾 路线图
|
||||
[**查看开发进度**](https://gitee.com/bootx/dax-pay/issues/I8TQ9Q)
|
||||
|
||||
### 2.0.X版本:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,8 +17,8 @@ public class DaxPayDemoProperties {
|
||||
/** 服务地址 */
|
||||
private String serverUrl;
|
||||
|
||||
/** 前端地址 */
|
||||
private String frontUrl;
|
||||
/** 前端地址(h5) */
|
||||
private String frontH5Url;
|
||||
|
||||
/** 签名方式 */
|
||||
private SignTypeEnum signType = SignTypeEnum.MD5;
|
||||
|
||||
@@ -82,12 +82,12 @@ public class AggregateService {
|
||||
boolean exists = redisClient.exists(PREFIX_KEY + code);
|
||||
if (!exists){
|
||||
// 跳转到过期页面
|
||||
return StrUtil.format("{}/result/error?msg={}", daxPayDemoProperties.getFrontUrl(), URLEncodeUtil.encode("聚合支付码已过期..."));
|
||||
return StrUtil.format("{}/result/error?msg={}", daxPayDemoProperties.getFrontH5Url(), URLEncodeUtil.encode("聚合支付码已过期..."));
|
||||
}
|
||||
// 根据UA判断是什么环境
|
||||
if (ua.contains(AggregatePayEnum.UA_ALI_PAY.getCode())) {
|
||||
// 跳转支付宝中间页
|
||||
return StrUtil.format("{}/aggregate/alipay?code={}", daxPayDemoProperties.getFrontUrl(),code);
|
||||
return StrUtil.format("{}/aggregate/alipay?code={}", daxPayDemoProperties.getFrontH5Url(),code);
|
||||
}
|
||||
else if (ua.contains(AggregatePayEnum.UA_WECHAT_PAY.getCode())) {
|
||||
// 微信重定向到中间页, 因为微信需要授权后才能发起支付
|
||||
@@ -95,7 +95,7 @@ public class AggregateService {
|
||||
}
|
||||
else {
|
||||
// 跳转到异常页
|
||||
return StrUtil.format("{}/result/error?msg={}", daxPayDemoProperties.getFrontUrl(), URLEncodeUtil.encode("请使用微信或支付宝扫码支付"));
|
||||
return StrUtil.format("{}/result/error?msg={}", daxPayDemoProperties.getFrontH5Url(), URLEncodeUtil.encode("请使用微信或支付宝扫码支付"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class AggregateService {
|
||||
// 获取微信OpenId
|
||||
String openId = this.getOpenId(authCode);
|
||||
return StrUtil.format("{}/aggregate/wechatPay?aggregateCode={}&openId={}",
|
||||
daxPayDemoProperties.getFrontUrl(),
|
||||
daxPayDemoProperties.getFrontH5Url(),
|
||||
aggregateCode,
|
||||
openId);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ public class AggregateService {
|
||||
// 异步回调地址
|
||||
simplePayParam.setNotNotify(true);
|
||||
// 同步回调地址 无效
|
||||
simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontUrl()));
|
||||
simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontH5Url()));
|
||||
|
||||
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(simplePayParam);
|
||||
// 判断是否支付成功
|
||||
@@ -185,9 +185,9 @@ public class AggregateService {
|
||||
// 异步回调地址
|
||||
simplePayParam.setNotNotify(true);
|
||||
// 支付成功同步回调地址
|
||||
simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontUrl()));
|
||||
simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontH5Url()));
|
||||
// 中途退出 目前经测试不生效
|
||||
simplePayParam.setQuitUrl(String.format("{}/result/error", daxPayDemoProperties.getFrontUrl()));
|
||||
simplePayParam.setQuitUrl(String.format("{}/result/error", daxPayDemoProperties.getFrontH5Url()));
|
||||
|
||||
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(simplePayParam);
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class CashierService {
|
||||
.orElse("127.0.0.1");
|
||||
simplePayParam.setClientIp(ip);
|
||||
// 同步回调地址
|
||||
simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontUrl()));
|
||||
simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontH5Url()));
|
||||
|
||||
// 发起支付
|
||||
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(simplePayParam);
|
||||
@@ -155,7 +155,7 @@ public class CashierService {
|
||||
* 获取手机收银台链接
|
||||
*/
|
||||
public String getUniCashierUrl() {
|
||||
return StrUtil.format("{}/cashier/uniCashier", daxPayDemoProperties.getFrontUrl());
|
||||
return StrUtil.format("{}/cashier/uniCashier", daxPayDemoProperties.getFrontH5Url());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +178,7 @@ public class CashierService {
|
||||
* 微信授权回调页面, 然后重定向到统一收银台中, 携带openid
|
||||
*/
|
||||
public String wxAuthCallback(String code) {
|
||||
return StrUtil.format("{}/cashier/uniCashier?source=redirect&openId={}", daxPayDemoProperties.getFrontUrl(), this.getOpenId(code));
|
||||
return StrUtil.format("{}/cashier/uniCashier?source=redirect&openId={}", daxPayDemoProperties.getFrontH5Url(), this.getOpenId(code));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,7 @@ package cn.bootx.platform.daxpay.sdk.net;
|
||||
import cn.bootx.platform.daxpay.sdk.code.SignTypeEnum;
|
||||
import cn.bootx.platform.daxpay.sdk.response.DaxPayResult;
|
||||
import cn.bootx.platform.daxpay.sdk.util.PaySignUtil;
|
||||
import cn.hutool.http.ContentType;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.http.*;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -63,7 +61,13 @@ public class DaxPayKit {
|
||||
.body(data, ContentType.JSON.getValue())
|
||||
.timeout(config.getReqTimeout())
|
||||
.execute();
|
||||
// 响应码只有200 才可以进行支付
|
||||
if (execute.getStatus() != HttpStatus.HTTP_OK){
|
||||
throw new HttpException("请求失败,请排查配置的支付网关地址是否正常");
|
||||
}
|
||||
String body = execute.body();
|
||||
|
||||
|
||||
log.debug("响应参数:{}", body);
|
||||
return request.toModel(body);
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ public class PayParam extends DaxPayRequest<PayOrderModel> {
|
||||
/** 商户扩展参数,回调时会原样返回 */
|
||||
private String attach;
|
||||
|
||||
/** 是否不进行同步通知的跳转 */
|
||||
private boolean notReturn;
|
||||
|
||||
/** 同步跳转URL, 部分接口不支持该配置,传输了也不会生效 */
|
||||
/**
|
||||
* 同步跳转URL, 不传输跳转到默认地址.
|
||||
* 部分接口不支持该配置,传输了也不会生效
|
||||
*/
|
||||
private String returnUrl;
|
||||
|
||||
/** 是否不启用异步通知 */
|
||||
|
||||
@@ -74,9 +74,6 @@ public class SimplePayParam extends DaxPayRequest<PayOrderModel> {
|
||||
/** 商户扩展参数,回调时会原样返回 */
|
||||
private String attach;
|
||||
|
||||
/** 是否不进行同步通知的跳转 */
|
||||
private boolean notReturn;
|
||||
|
||||
/** 同步跳转URL, 部分接口不支持该配置,传输了也不会生效 */
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
@@ -26,9 +26,6 @@ public class QueryRefundOrderParam extends DaxPayRequest<QueryRefundOrderModel>
|
||||
/** 商户扩展参数,回调时会原样返回 */
|
||||
private String attach;
|
||||
|
||||
/** 是否不进行同步通知的跳转 */
|
||||
private boolean notReturn;
|
||||
|
||||
/** 同步跳转URL, 部分接口不支持该配置,传输了也不会生效 */
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ public class PayOrderTest {
|
||||
PayParam param = new PayParam();
|
||||
param.setClientIp("127.0.0.1");
|
||||
param.setNotNotify(true);
|
||||
param.setNotReturn(true);
|
||||
|
||||
param.setBusinessNo("P0001");
|
||||
param.setTitle("测试接口支付");
|
||||
|
||||
@@ -38,7 +38,6 @@ public class SimplePayOrderTest {
|
||||
param.setPayWay(PayWayEnum.QRCODE.getCode());
|
||||
param.setClientIp("127.0.0.1");
|
||||
param.setNotNotify(true);
|
||||
param.setNotReturn(true);
|
||||
|
||||
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(param);
|
||||
System.out.println(execute);
|
||||
|
||||
@@ -29,7 +29,6 @@ public class PayParamSignTest {
|
||||
PayParam param = new PayParam();
|
||||
param.setClientIp("127.0.0.1");
|
||||
param.setNotNotify(true);
|
||||
param.setNotReturn(true);
|
||||
|
||||
param.setBusinessNo("P0001");
|
||||
param.setTitle("测试接口支付");
|
||||
|
||||
@@ -51,11 +51,8 @@ public class PayParam extends PaymentCommonParam {
|
||||
@Schema(description = "商户扩展参数,回调时会原样返回")
|
||||
private String attach;
|
||||
|
||||
@Schema(description = "是否不进行同步通知的跳转")
|
||||
private boolean notReturn;
|
||||
|
||||
/** 同步通知URL */
|
||||
@Schema(description = "同步通知URL")
|
||||
/** 同步跳转URL, 不传输跳转到默认地址 */
|
||||
@Schema(description = "同步跳转URL")
|
||||
private String returnUrl;
|
||||
|
||||
/** 是否不启用异步通知 */
|
||||
|
||||
@@ -79,10 +79,7 @@ public class SimplePayParam extends PaymentCommonParam {
|
||||
@Schema(description = "商户扩展参数,回调时会原样返回")
|
||||
private String attach;
|
||||
|
||||
@Schema(description = "是否不进行同步通知的跳转")
|
||||
private boolean notReturn;
|
||||
|
||||
/** 同步通知URL */
|
||||
/** 同步跳转URL, 不传输跳转到默认地址 */
|
||||
@Schema(description = "同步通知URL")
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* @since 2024/1/13
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@Tag(name = "支付同步通知控制器")
|
||||
@Tag(name = "支付同步通知")
|
||||
@RestController
|
||||
@RequestMapping("/pay/return")
|
||||
@RequestMapping("/return/pay")
|
||||
@RequiredArgsConstructor
|
||||
public class PayReturnController {
|
||||
private final PayReturnService payReturnService;
|
||||
|
||||
@Operation(summary = "支付宝同步通知")
|
||||
@Operation(summary = "支付宝同步跳转连接")
|
||||
@GetMapping("/alipay")
|
||||
public ModelAndView alipay(AliPayReturnParam param){
|
||||
String url = payReturnService.alipay(param);
|
||||
|
||||
@@ -16,6 +16,9 @@ public class DaxPayProperties {
|
||||
/** 服务地址 */
|
||||
private String serverUrl;
|
||||
|
||||
/** 前端地址 */
|
||||
private String frontUrl;
|
||||
/** 前端地址(h5) */
|
||||
private String frontH5Url;
|
||||
|
||||
/** 前端地址(web) */
|
||||
private String frontWebUrl;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.bootx.platform.daxpay.service.core.order.pay.dao.PayOrderExtraManager;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrderExtra;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayOrderQueryService;
|
||||
import cn.bootx.platform.daxpay.service.core.system.config.service.PlatformConfigService;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayReturnParam;
|
||||
import cn.hutool.core.net.URLEncodeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -25,6 +26,7 @@ import java.util.Objects;
|
||||
public class PayReturnService {
|
||||
private final PayOrderQueryService payOrderQueryService;
|
||||
private final PayOrderExtraManager payOrderExtraManager;
|
||||
private final PlatformConfigService platformConfigService;
|
||||
|
||||
private final DaxPayProperties properties;
|
||||
|
||||
@@ -35,13 +37,18 @@ public class PayReturnService {
|
||||
PayOrderExtra payOrderExtra = payOrderExtraManager.findById(param.getOut_trade_no()).orElse(null);
|
||||
PayOrder prOrder = payOrderQueryService.findById(param.getOut_trade_no()).orElse(null);
|
||||
if (Objects.isNull(payOrderExtra) || Objects.isNull(prOrder)){
|
||||
return StrUtil.format("{}/result/error?msg={}", properties.getFrontUrl(), URLEncodeUtil.encode("支付订单有问题,请排查"));
|
||||
return StrUtil.format("{}/result/error?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付订单有问题,请排查"));
|
||||
}
|
||||
|
||||
// 如果不需要同步回调, 跳转到支付成功页面
|
||||
if (payOrderExtra.isNotReturn()){
|
||||
return StrUtil.format("{}/result/success?msg={}", properties.getFrontUrl(), URLEncodeUtil.encode("支付成功..."));
|
||||
// 如果同步跳转参数为空, 获取系统配置地址, 系统配置如果也为空, 则返回默认地址
|
||||
String returnUrl = payOrderExtra.getReturnUrl();
|
||||
if (StrUtil.isBlank(returnUrl)){
|
||||
returnUrl = platformConfigService.getConfig().getReturnUrl();
|
||||
}
|
||||
return StrUtil.format("{}?paymentId={}&businessNo={}", payOrderExtra.getReturnUrl(),prOrder.getId(),prOrder.getBusinessNo());
|
||||
if (StrUtil.isNotBlank(returnUrl)){
|
||||
return StrUtil.format("{}?paymentId={}&businessNo={}", payOrderExtra.getReturnUrl(),prOrder.getId(),prOrder.getBusinessNo());
|
||||
}
|
||||
// 跳转到默认页
|
||||
return StrUtil.format("{}/result/success?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付成功..."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ public class PayBuilder {
|
||||
.setDescription(payParam.getDescription())
|
||||
.setNotNotify(payParam.isNotNotify())
|
||||
.setNotifyUrl(noticeInfo.getNotifyUrl())
|
||||
.setNotReturn(payParam.isNotReturn())
|
||||
.setReturnUrl(noticeInfo.getReturnUrl())
|
||||
.setSign(payParam.getSign())
|
||||
.setSignType(platform.getSignType())
|
||||
|
||||
@@ -45,10 +45,6 @@ public class PayOrderExtra extends MpBaseEntity implements EntityBaseFunction<Pa
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String notifyUrl;
|
||||
|
||||
/** 是否不需要同步调转通知 */
|
||||
@DbColumn(comment = "是否不需要同步调转通知")
|
||||
private boolean notReturn;
|
||||
|
||||
/** 同步调转地址 */
|
||||
@DbColumn(comment = "同步调转地址,以最后一次为准")
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
|
||||
@@ -104,9 +104,7 @@ public class PayAssistService {
|
||||
}
|
||||
}
|
||||
// 同步回调
|
||||
if (!payParam.isNotReturn()){
|
||||
noticeInfo.setReturnUrl(payParam.getReturnUrl());
|
||||
}
|
||||
noticeInfo.setReturnUrl(payParam.getReturnUrl());
|
||||
// 退出回调地址
|
||||
noticeInfo.setQuitUrl(payParam.getQuitUrl());
|
||||
}
|
||||
@@ -161,7 +159,6 @@ public class PayAssistService {
|
||||
.setSign(payParam.getSign())
|
||||
.setNotNotify(payParam.isNotNotify())
|
||||
.setNotifyUrl(notifyUrl)
|
||||
.setNotReturn(payParam.isNotReturn())
|
||||
.setReturnUrl(returnUrl)
|
||||
.setAttach(payParam.getAttach())
|
||||
.setClientIp(payParam.getClientIp());
|
||||
|
||||
@@ -35,7 +35,7 @@ public class WeChatPayConfigDto extends BaseDto implements Serializable {
|
||||
@Schema(description = "异步通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@Schema(description = "同步通知地址")
|
||||
@Schema(description = "同步跳转地址")
|
||||
private String returnUrl;
|
||||
|
||||
@Schema(description = "商户平台「API安全」中的 APIv2 密钥")
|
||||
|
||||
@@ -30,7 +30,7 @@ public class PlatformConfigDto {
|
||||
@Schema(description ="异步支付通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@Schema(description ="同步支付通知地址")
|
||||
@Schema(description ="同步支付跳转地址")
|
||||
private String returnUrl;
|
||||
|
||||
@Schema(description ="订单默认超时时间(分钟)")
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PlatformConfigParam {
|
||||
@DbColumn(comment = "支付通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@Schema(description ="同步支付通知地址")
|
||||
@Schema(description ="同步支付跳转地址")
|
||||
private String returnUrl;
|
||||
|
||||
@DbColumn(comment = "订单默认超时时间")
|
||||
|
||||
@@ -28,7 +28,6 @@ class PayParamSignTest {
|
||||
payParam.setBusinessNo("123");
|
||||
payParam.setClientIp("127.0.0.1");
|
||||
payParam.setNotNotify(true);
|
||||
payParam.setNotReturn(true);
|
||||
payParam.setNotifyUrl("http://127.0.0.1:8080/pay/notify");
|
||||
payParam.setReturnUrl("http://127.0.0.1:8080/pay/return");
|
||||
payParam.setVersion("1.0");
|
||||
|
||||
@@ -157,13 +157,15 @@ dromara:
|
||||
dax-pay:
|
||||
# 网关地址
|
||||
server-url: http://pay1.bootx.cn
|
||||
# 前端地址
|
||||
front-url: http://pay1.bootx.cn/h5/#
|
||||
# 前端h5地址
|
||||
front-h5-url: http://pay1.bootx.cn/h5/#
|
||||
# 前端web地址
|
||||
front-web-url: http://pay1.bootx.cn/#
|
||||
# 演示模块
|
||||
demo:
|
||||
# 网关地址
|
||||
server-url: http://pay1.bootx.cn
|
||||
# 前端地址
|
||||
front-url: http://pay1.bootx.cn/h5/#
|
||||
# 前端h5地址
|
||||
front-h5-url: http://pay1.bootx.cn/h5/#
|
||||
# 签名秘钥
|
||||
sign-secret: 123456
|
||||
|
||||
@@ -4,9 +4,12 @@ services:
|
||||
image: dax-start:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "9898:9898"
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
# 读取外部化配置文件(根据实际服务器环境做修改), 宿主机目录:容器目录
|
||||
- /data/logs/dax-start:/logs # 日志
|
||||
- /root/dax-pay/application-dev.yml:/application-dev.yml # 配置
|
||||
- /root/dax-pay/logback-spring.xml:/logback-spring.xml # 日志框架
|
||||
- ./logs/:/logs # 日志
|
||||
- ./files/:/data/files # 上传文件目录
|
||||
- ./application.yml:/application.yml # 启动配置文件
|
||||
- ./application-demo.yml:/application-demo.yml
|
||||
- ./logback-spring.xml:/logback-spring.xml # 日志框架配置
|
||||
- ./ip2region/ip2region.xdb :/data/ip2region/ip2region.xdb # ip归属地数据库
|
||||
|
||||
Reference in New Issue
Block a user