mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-13 21:30:25 +00:00
build sql脚本和sdk更新
This commit is contained in:
5790
_config/mysql/datas.sql
Normal file
5790
_config/mysql/datas.sql
Normal file
File diff suppressed because it is too large
Load Diff
1197
_config/mysql/tables.sql
Normal file
1197
_config/mysql/tables.sql
Normal file
File diff suppressed because it is too large
Load Diff
5790
_config/postgresql/datas.sql
Normal file
5790
_config/postgresql/datas.sql
Normal file
File diff suppressed because it is too large
Load Diff
3007
_config/postgresql/tables.sql
Normal file
3007
_config/postgresql/tables.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
package org.dromara.daxpay.sdk.net;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.dromara.daxpay.sdk.code.SignTypeEnum;
|
||||
|
||||
/**
|
||||
* 代理商配置
|
||||
* @author xxm
|
||||
* @since 2025/8/24
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
public class DaxPayAgentConfig {
|
||||
/** 服务地址 */
|
||||
private String serviceUrl;
|
||||
|
||||
/** 代理商号 */
|
||||
private String agentNo;
|
||||
|
||||
/** 签名方式 */
|
||||
@Builder.Default
|
||||
private SignTypeEnum signType = SignTypeEnum.HMAC_SHA256;
|
||||
|
||||
/** 签名秘钥 */
|
||||
private String signSecret;
|
||||
|
||||
/** 请求超时时间 */
|
||||
@Builder.Default
|
||||
private int reqTimeout = 30000;
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
package org.dromara.daxpay.sdk.net;
|
||||
|
||||
import org.dromara.daxpay.sdk.code.SignTypeEnum;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import org.dromara.daxpay.sdk.util.PaySignUtil;
|
||||
import cn.hutool.http.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 支付发起工具包
|
||||
* @author xxm
|
||||
* @since 2024/2/2
|
||||
*/
|
||||
@Slf4j
|
||||
public class DaxPayAgentKit {
|
||||
|
||||
private final DaxPayAgentConfig config;
|
||||
|
||||
public DaxPayAgentKit(DaxPayAgentConfig config) {
|
||||
log.debug("DaxPayKit初始化...");
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付请求执行类, 默认对请求参数进行签名
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @param <T> 业务对象
|
||||
* @return DaxResult 响应类
|
||||
*/
|
||||
public <T> DaxResult<T> execute(DaxPayAgentRequest<T> request) {
|
||||
return execute(request, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付请求执行类
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @param sign 是否进行签名
|
||||
* @param <T> 业务对象
|
||||
* @return DaxResult 响应类
|
||||
*/
|
||||
public <T> DaxResult<T> execute(DaxPayAgentRequest<T> request, boolean sign) {
|
||||
// 判断是否需要填充商户号和应用号
|
||||
if (Objects.isNull(request.getAgentNo())) {
|
||||
request.setAgentNo(config.getAgentNo());
|
||||
}
|
||||
// 判断是是否进行签名
|
||||
if (sign) {
|
||||
if (Objects.equals(SignTypeEnum.MD5, config.getSignType())) {
|
||||
request.setSign(PaySignUtil.md5Sign(request, config.getSignSecret()));
|
||||
} else if (Objects.equals(SignTypeEnum.HMAC_SHA256, config.getSignType())) {
|
||||
request.setSign(PaySignUtil.hmacSha256Sign(request, config.getSignSecret()));
|
||||
} else if (Objects.equals(SignTypeEnum.SM3, config.getSignType())) {
|
||||
request.setSign(PaySignUtil.sm3Sign(request, config.getSignSecret()));
|
||||
}
|
||||
}
|
||||
// 参数序列化
|
||||
String data = JsonUtil.toJsonStr(request);
|
||||
log.debug("请求参数:{}", data);
|
||||
|
||||
String path = config.getServiceUrl() + request.path();
|
||||
String body;
|
||||
try (HttpResponse execute = HttpUtil.createPost(path)
|
||||
.body(data, ContentType.JSON.getValue())
|
||||
.timeout(config.getReqTimeout())
|
||||
.execute()) {
|
||||
// 响应码只有200 正常
|
||||
if (execute.getStatus() != HttpStatus.HTTP_OK) {
|
||||
log.error("请求第支付网关失败,请排查配置的支付网关地址是否正常");
|
||||
throw new HttpException("请求失败,内部异常");
|
||||
}
|
||||
body = execute.body();
|
||||
}
|
||||
log.debug("响应参数:{}", body);
|
||||
return request.toModel(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验签
|
||||
*/
|
||||
public boolean verifySign(DaxResult<?> result) {
|
||||
String sign = result.getSign();
|
||||
// 如果签名值为空, 不需要进行验签
|
||||
if (Objects.isNull(sign)){
|
||||
return true;
|
||||
}
|
||||
if (Objects.equals(SignTypeEnum.MD5, config.getSignType())) {
|
||||
return PaySignUtil.verifyMd5Sign(result, config.getSignSecret(), sign);
|
||||
} else if (Objects.equals(SignTypeEnum.HMAC_SHA256, config.getSignType())) {
|
||||
return PaySignUtil.verifyHmacSha256Sign(result, config.getSignSecret(), sign);
|
||||
} else if (Objects.equals(SignTypeEnum.SM3, config.getSignType())) {
|
||||
return PaySignUtil.verifySm3Sign(result, config.getSignSecret(), sign);
|
||||
}
|
||||
throw new IllegalArgumentException("未获取到签名方式,请检查");
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package org.dromara.daxpay.sdk.net;
|
||||
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 请求接口
|
||||
* @author xxm
|
||||
* @since 2024/2/2
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class DaxPayAgentRequest<T> {
|
||||
|
||||
/** 代理商号 */
|
||||
@Schema(description = "代理商号")
|
||||
@NotBlank(message = "代理商号不可为空")
|
||||
@Size(max = 32, message = "代理商号不可超过32位")
|
||||
private String agentNo;
|
||||
|
||||
/** 客户端ip */
|
||||
@Schema(description = "客户端ip")
|
||||
@Size(max=64, message = "客户端ip不可超过64位")
|
||||
private String clientIp;
|
||||
|
||||
/** 签名 */
|
||||
@Schema(description = "签名")
|
||||
@Size(max = 64, message = "签名不可超过64位")
|
||||
private String sign;
|
||||
|
||||
/** 请求时间 格式yyyy-MM-dd HH:mm:ss */
|
||||
@Schema(description = "请求时间, 格式yyyy-MM-dd HH:mm:ss")
|
||||
@NotNull(message = "请求时间必填")
|
||||
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
|
||||
private LocalDateTime reqTime = LocalDateTime.now();
|
||||
|
||||
/** 随机数 */
|
||||
@Schema(description = "随机数")
|
||||
@Size(max = 32, message = "随机数不可超过32位")
|
||||
private String nonceStr;
|
||||
|
||||
/**
|
||||
* 方法请求路径
|
||||
* @return 请求路径
|
||||
*/
|
||||
public abstract String path();
|
||||
|
||||
/**
|
||||
* 将请求返回结果反序列化为实体类
|
||||
* @param json json字符串
|
||||
* @return 反序列后的对象
|
||||
*/
|
||||
public abstract DaxResult<T> toModel(String json);
|
||||
|
||||
}
|
@@ -17,6 +17,9 @@ public class DaxPayConfig {
|
||||
/** 服务地址 */
|
||||
private String serviceUrl;
|
||||
|
||||
/** 商户号 */
|
||||
private String mchNo;
|
||||
|
||||
/** 应用号 */
|
||||
private String appId;
|
||||
|
||||
|
@@ -5,7 +5,6 @@ import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import org.dromara.daxpay.sdk.util.PaySignUtil;
|
||||
import cn.hutool.http.*;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -16,14 +15,13 @@ import java.util.Objects;
|
||||
* @since 2024/2/2
|
||||
*/
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public class DaxPayKit {
|
||||
|
||||
private DaxPayConfig config;
|
||||
private final DaxPayConfig config;
|
||||
|
||||
public void initConfig(DaxPayConfig config) {
|
||||
public DaxPayKit(DaxPayConfig config) {
|
||||
log.debug("DaxPayKit初始化...");
|
||||
DaxPayKit.config = config;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,6 +44,10 @@ public class DaxPayKit {
|
||||
* @return DaxResult 响应类
|
||||
*/
|
||||
public <T> DaxResult<T> execute(DaxPayRequest<T> request, boolean sign) {
|
||||
// 判断是否需要填充商户号和应用号
|
||||
if (Objects.isNull(request.getMchNo())) {
|
||||
request.setMchNo(config.getMchNo());
|
||||
}
|
||||
if (Objects.isNull(request.getAppId())) {
|
||||
request.setAppId(config.getAppId());
|
||||
}
|
||||
|
@@ -21,6 +21,12 @@ import java.time.LocalDateTime;
|
||||
@Setter
|
||||
public abstract class DaxPayRequest<T> {
|
||||
|
||||
/** 商户号 */
|
||||
@Schema(description = "商户号")
|
||||
@NotBlank(message = "商户号不可为空")
|
||||
@Size(max = 32, message = "商户号不可超过32位")
|
||||
private String mchNo;
|
||||
|
||||
/** 应用号 */
|
||||
@Schema(description = "应用号")
|
||||
@NotBlank(message = "应用号不可为空")
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package org.dromara.daxpay.sdk.param.channel;
|
||||
package org.dromara.daxpay.sdk.param.channel.adapay;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -18,6 +18,4 @@ public class AdaPayParam {
|
||||
/** 买家支付宝账号 */
|
||||
private String buyerLogonId;
|
||||
|
||||
/** openid */
|
||||
private String openId;
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package org.dromara.daxpay.sdk.param.channel;
|
||||
package org.dromara.daxpay.sdk.param.channel.alipay;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
@@ -0,0 +1,44 @@
|
||||
package org.dromara.daxpay.sdk.param.channel.hkrt;
|
||||
|
||||
import org.dromara.daxpay.sdk.net.DaxPayAgentRequest;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.channel.hkrt.HkrtForwardResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 海科接口转发参数
|
||||
* @author xxm
|
||||
* @since 2025/8/24
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "海科接口转发参数")
|
||||
public class HkrtAgentForwardParam extends DaxPayAgentRequest<HkrtForwardResult> {
|
||||
@NotBlank(message = "接口路径不可为空")
|
||||
@Schema(description = "接口路径")
|
||||
private String method;
|
||||
|
||||
@NotEmpty(message = "参数不可为空")
|
||||
@Schema(description = "参数")
|
||||
private Map<String,Object> param;
|
||||
|
||||
@Override
|
||||
public String path() {
|
||||
return "/unipay/forward/hkrt/agent";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaxResult<HkrtForwardResult> toModel(String json) {
|
||||
return JsonUtil.toBean(json, new TypeReference<DaxResult<HkrtForwardResult>>() {});
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package org.dromara.daxpay.sdk.param.channel.hkrt;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 海科支付参数
|
||||
* @author xxm
|
||||
* @since 2025/5/16
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "海科支付参数")
|
||||
public class HkrtPayParam {
|
||||
|
||||
/** 微信公众账号ID */
|
||||
@Schema(description = "微信公众账号ID")
|
||||
private String wxAppId;
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package org.dromara.daxpay.sdk.param.channel.leshua;
|
||||
|
||||
import org.dromara.daxpay.sdk.net.DaxPayAgentRequest;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.channel.leshua.LeshuaForwardResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 乐刷代理商接口转发参数
|
||||
* @author xxm
|
||||
* @since 2025/8/24
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "乐刷代理商接口转发参数")
|
||||
public class LeshuaAgentForwardParam extends DaxPayAgentRequest<LeshuaForwardResult> {
|
||||
@NotBlank(message = "接口路径不可为空")
|
||||
@Schema(description = "接口路径")
|
||||
private String method;
|
||||
|
||||
@NotBlank(message = "参数不可为空")
|
||||
@Schema(description = "参数")
|
||||
private String param;
|
||||
|
||||
@Override
|
||||
public String path() {
|
||||
return "/unipay/forward/leshua/agent";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaxResult<LeshuaForwardResult> toModel(String json) {
|
||||
return JsonUtil.toBean(json, new TypeReference<DaxResult<LeshuaForwardResult>>() {});
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package org.dromara.daxpay.sdk.param.channel;
|
||||
package org.dromara.daxpay.sdk.param.channel.union;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@@ -0,0 +1,44 @@
|
||||
package org.dromara.daxpay.sdk.param.channel.vbill;
|
||||
|
||||
import org.dromara.daxpay.sdk.net.DaxPayAgentRequest;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.channel.vbill.VbillForwardResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 随行付接口转发参数
|
||||
* @author xxm
|
||||
* @since 2025/8/24
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "海科接口转发参数")
|
||||
public class VbillAgentForwardParam extends DaxPayAgentRequest<VbillForwardResult> {
|
||||
@NotBlank(message = "接口路径不可为空")
|
||||
@Schema(description = "接口路径")
|
||||
private String method;
|
||||
|
||||
@NotEmpty(message = "参数不可为空")
|
||||
@Schema(description = "参数")
|
||||
private Map<String,Object> param;
|
||||
|
||||
@Override
|
||||
public String path() {
|
||||
return "/unipay/forward/vbill/agent";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaxResult<VbillForwardResult> toModel(String json) {
|
||||
return JsonUtil.toBean(json, new TypeReference<DaxResult<VbillForwardResult>>() {});
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package org.dromara.daxpay.sdk.param.channel;
|
||||
package org.dromara.daxpay.sdk.param.channel.wechat;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
@@ -25,7 +25,7 @@ import java.time.LocalDateTime;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "网关付款码支付参数")
|
||||
@Schema(title = "网关聚合付款码支付参数")
|
||||
public class AggregateBarPayParam extends DaxPayRequest<PayResult> {
|
||||
|
||||
/** 商户订单号 */
|
||||
|
@@ -26,6 +26,7 @@ import java.time.LocalDateTime;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "网关支付参数")
|
||||
public class GatewayPayParam extends DaxPayRequest<GatewayPayUrlResult> {
|
||||
|
||||
/** 商户订单号 */
|
||||
@@ -45,6 +46,11 @@ public class GatewayPayParam extends DaxPayRequest<GatewayPayUrlResult> {
|
||||
@Size(max = 500, message = "支付描述不可超过500位")
|
||||
private String description;
|
||||
|
||||
/** 自定义OpenId 微信类通道可用 */
|
||||
@Schema(description = "自定义OpenId")
|
||||
@Size(max = 64, message = "自定义OpenId不可超过64位")
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 网关支付类型
|
||||
* @see GatewayPayTypeEnum
|
||||
|
@@ -6,16 +6,19 @@ import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付关闭参数
|
||||
* @author xxm
|
||||
* @since 2023/12/17
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "支付关闭参数")
|
||||
public class PayCloseParam extends DaxPayRequest<Void> {
|
||||
|
||||
|
||||
|
@@ -12,8 +12,9 @@ import cn.hutool.core.lang.TypeReference;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -23,8 +24,10 @@ import java.time.LocalDateTime;
|
||||
* @author xxm
|
||||
* @since 2024/2/2
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "支付参数")
|
||||
public class PayParam extends DaxPayRequest<PayResult> {
|
||||
|
||||
/** 商户订单号 */
|
||||
@@ -141,7 +144,7 @@ public class PayParam extends DaxPayRequest<PayResult> {
|
||||
private String notifyUrl;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 方法请求路径
|
||||
*/
|
||||
@Override
|
||||
|
@@ -1,22 +1,25 @@
|
||||
package org.dromara.daxpay.sdk.param.trade.pay;
|
||||
|
||||
import org.dromara.daxpay.sdk.net.DaxPayRequest;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.trade.pay.PayOrderResult;
|
||||
import org.dromara.daxpay.sdk.net.DaxPayRequest;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付单查询参数
|
||||
* 支付查询参数
|
||||
* @author xxm
|
||||
* @since 2024/1/16
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "支付查询参数")
|
||||
public class QueryPayParam extends DaxPayRequest<PayOrderResult> {
|
||||
|
||||
|
||||
|
@@ -1,14 +1,15 @@
|
||||
package org.dromara.daxpay.sdk.param.trade.refund;
|
||||
|
||||
import org.dromara.daxpay.sdk.net.DaxPayRequest;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.trade.refund.RefundOrderResult;
|
||||
import org.dromara.daxpay.sdk.net.DaxPayRequest;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 查询退款订单参数类
|
||||
@@ -17,6 +18,8 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "查询退款订单参数类")
|
||||
public class QueryRefundParam extends DaxPayRequest<RefundOrderResult> {
|
||||
|
||||
/** 退款号 */
|
||||
|
@@ -7,9 +7,9 @@ import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -18,9 +18,10 @@ import java.math.BigDecimal;
|
||||
* @author xxm
|
||||
* @since 2023/12/18
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "退款参数")
|
||||
public class RefundParam extends DaxPayRequest<RefundResult> {
|
||||
|
||||
|
||||
|
@@ -1,24 +1,25 @@
|
||||
package org.dromara.daxpay.sdk.param.trade.transfer;
|
||||
|
||||
import org.dromara.daxpay.sdk.result.trade.transfer.TransferOrderResult;
|
||||
import org.dromara.daxpay.sdk.net.DaxPayRequest;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.trade.transfer.TransferOrderResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* 转账查询参数
|
||||
* @author xxm
|
||||
* @since 2024/6/20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "转账查询参数")
|
||||
public class QueryTransferParam extends DaxPayRequest<TransferOrderResult> {
|
||||
/** 商户转账号 */
|
||||
@Size(max = 100, message = "商户转账号不可超过100位")
|
||||
|
@@ -2,16 +2,16 @@ package org.dromara.daxpay.sdk.param.trade.transfer;
|
||||
|
||||
import org.dromara.daxpay.sdk.code.ChannelEnum;
|
||||
import org.dromara.daxpay.sdk.code.TransferPayeeTypeEnum;
|
||||
import org.dromara.daxpay.sdk.result.trade.transfer.TransferResult;
|
||||
import org.dromara.daxpay.sdk.net.DaxPayRequest;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.trade.transfer.TransferResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -20,9 +20,10 @@ import java.math.BigDecimal;
|
||||
* @author xxm
|
||||
* @since 2024/6/19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "转账参数")
|
||||
public class TransferParam extends DaxPayRequest<TransferResult> {
|
||||
|
||||
/** 商户转账号 */
|
||||
|
@@ -20,6 +20,10 @@ public class DaxNoticeResult<T> extends DaxResult<T>{
|
||||
@Schema(description = "通知类型")
|
||||
private String noticeType;
|
||||
|
||||
/** 商户号 */
|
||||
@Schema(description = "商户号")
|
||||
private String mchNo;
|
||||
|
||||
/** 应用ID */
|
||||
@Schema(description = "应用ID")
|
||||
private String appId;
|
||||
|
@@ -0,0 +1,27 @@
|
||||
package org.dromara.daxpay.sdk.result.channel.hkrt;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 海科接口转发返回结果
|
||||
* @author xxm
|
||||
* @since 2025/8/24
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "海科接口转发返回结果")
|
||||
public class HkrtForwardResult {
|
||||
|
||||
@Schema(description = "是否成功")
|
||||
private boolean success;
|
||||
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMsg;
|
||||
|
||||
@Schema(description = "返回结果")
|
||||
private Map<String, Object> map;
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package org.dromara.daxpay.sdk.result.channel.leshua;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 这刷接口转发返回结果
|
||||
* @author xxm
|
||||
* @since 2025/8/24
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "这刷接口转发返回结果")
|
||||
public class LeshuaForwardResult {
|
||||
|
||||
@Schema(description = "是否成功")
|
||||
private boolean success;
|
||||
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMsg;
|
||||
|
||||
@Schema(description = "返回结果")
|
||||
private Map<String, Object> map;
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package org.dromara.daxpay.sdk.result.channel.vbill;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 随行付接口转发返回结果
|
||||
* @author xxm
|
||||
* @since 2025/8/24
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "随行付接口转发返回结果")
|
||||
public class VbillForwardResult {
|
||||
|
||||
@Schema(description = "是否成功")
|
||||
private boolean success;
|
||||
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMsg;
|
||||
|
||||
@Schema(description = "返回结果")
|
||||
private Map<String, Object> map;
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
package org.dromara.daxpay.sdk.result.notice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 分账明细
|
||||
* @author xxm
|
||||
* @since 2024/5/30
|
||||
*/
|
||||
@Data
|
||||
public class AllocDetailNoticeResult {
|
||||
|
||||
/** 分账接收方编号 */
|
||||
private String receiverNo;
|
||||
|
||||
/** 分账金额 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 分账接收方类型
|
||||
* @see AllocReceiverTypeEnum
|
||||
*/
|
||||
private String receiverType;
|
||||
|
||||
/** 接收方账号 */
|
||||
private String receiverAccount;
|
||||
|
||||
/** 接收方姓名 */
|
||||
private String receiverName;
|
||||
|
||||
/**
|
||||
* 分账结果
|
||||
* @see AllocDetailResultEnum
|
||||
*/
|
||||
private String result;
|
||||
|
||||
/** 错误代码 */
|
||||
private String errorCode;
|
||||
|
||||
/** 错误原因 */
|
||||
private String errorMsg;
|
||||
|
||||
/** 分账完成时间 */
|
||||
private Long finishTime;
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
package org.dromara.daxpay.sdk.result.notice;
|
||||
|
||||
import org.dromara.daxpay.sdk.code.ChannelEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分账异步通知类
|
||||
* @author xxm
|
||||
* @since 2024/5/21
|
||||
*/
|
||||
@Data
|
||||
public class AllocNoticeResult {
|
||||
/**
|
||||
* 分账单号
|
||||
*/
|
||||
private String allocNo;
|
||||
|
||||
/**
|
||||
* 商户分账单号
|
||||
*/
|
||||
private String bizAllocNo;
|
||||
|
||||
/**
|
||||
* 通道分账号
|
||||
*/
|
||||
private String outAllocNo;
|
||||
|
||||
/**
|
||||
* 支付订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 商户支付订单号
|
||||
*/
|
||||
private String bizOrderNo;
|
||||
|
||||
|
||||
/**
|
||||
* 支付订单标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 所属通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
private String channel;
|
||||
|
||||
/**
|
||||
* 总分账金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 分账描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* @see AllocOrderStatusEnum
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 处理结果
|
||||
* @see AllocOrderResultEnum
|
||||
*/
|
||||
private String result;
|
||||
|
||||
/** 分账订单完成时间 */
|
||||
private Long finishTime;
|
||||
|
||||
/** 商户扩展参数 */
|
||||
private String attach;
|
||||
|
||||
/** 分账明细 */
|
||||
private List<AllocDetailNoticeResult> details;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
private String errorMsg;
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
package org.dromara.daxpay.sdk.result.notice;
|
||||
|
||||
import org.dromara.daxpay.sdk.code.ChannelEnum;
|
||||
import org.dromara.daxpay.sdk.code.PayAllocStatusEnum;
|
||||
import org.dromara.daxpay.sdk.code.PayRefundStatusEnum;
|
||||
import org.dromara.daxpay.sdk.code.PayStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付异步通知类
|
||||
* @author xxm
|
||||
* @since 2024/1/7
|
||||
*/
|
||||
@Data
|
||||
public class PayNoticeResult {
|
||||
|
||||
/** 订单号 */
|
||||
private String orderNo;
|
||||
|
||||
/** 商户订单号 */
|
||||
private String bizOrderNo;
|
||||
|
||||
/** 通道系统交易号 */
|
||||
private String outOrderNo;
|
||||
|
||||
/** 标题 */
|
||||
private String title;
|
||||
|
||||
/** 描述 */
|
||||
private String description;
|
||||
|
||||
/** 是否支持分账 */
|
||||
private Boolean allocation;
|
||||
|
||||
/** 是否开启自动分账,*/
|
||||
private Boolean autoAllocation;
|
||||
/**
|
||||
* 支付通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
private String channel;
|
||||
|
||||
/** 支付方式 */
|
||||
private String method;
|
||||
|
||||
/** 支付金额 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 支付状态
|
||||
* @see PayStatusEnum
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
||||
/**
|
||||
* 退款状态
|
||||
* @see PayRefundStatusEnum
|
||||
*/
|
||||
private String refundStatus;
|
||||
|
||||
/**
|
||||
* 分账状态
|
||||
* @see PayAllocStatusEnum
|
||||
*/
|
||||
private String allocStatus;
|
||||
|
||||
/** 支付成功时间 */
|
||||
private Long payTime;
|
||||
|
||||
/** 过期时间 */
|
||||
private Long expiredTime;
|
||||
|
||||
/** 支付关闭时间 */
|
||||
private Long closeTime;
|
||||
|
||||
/** 支付创建时间 */
|
||||
private Long createTime;
|
||||
|
||||
/** 商户扩展参数,回调时会原样返回 */
|
||||
private String attach;
|
||||
|
||||
/** 错误码 */
|
||||
private String errorCode;
|
||||
|
||||
/** 错误原因 */
|
||||
private String errorMsg;
|
||||
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
package org.dromara.daxpay.sdk.result.notice;
|
||||
|
||||
import org.dromara.daxpay.sdk.code.ChannelEnum;
|
||||
import org.dromara.daxpay.sdk.code.RefundStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 退款通知消息
|
||||
* @author xxm
|
||||
* @since 2024/2/22
|
||||
*/
|
||||
@Data
|
||||
public class RefundNoticeResult {
|
||||
|
||||
/** 支付订单号 */
|
||||
private String orderNo;
|
||||
|
||||
/** 商户支付订单号 */
|
||||
private String bizOrderNo;
|
||||
|
||||
/** 通道支付订单号 */
|
||||
private String outOrderNo;
|
||||
|
||||
/** 支付标题 */
|
||||
private String title;
|
||||
|
||||
/** 退款号 */
|
||||
private String refundNo;
|
||||
|
||||
/** 商户退款号 */
|
||||
private String bizRefundNo;
|
||||
|
||||
/** 通道退款交易号 */
|
||||
private String outRefundNo;
|
||||
|
||||
/**
|
||||
* 退款通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
private String channel;
|
||||
|
||||
/** 订单金额 */
|
||||
private Integer orderAmount;
|
||||
|
||||
/** 退款金额 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 退款原因 */
|
||||
private String reason;
|
||||
|
||||
/** 退款成功时间 */
|
||||
private Long finishTime;
|
||||
|
||||
/** 退款创建时间 */
|
||||
private Long createTime;
|
||||
/**
|
||||
* 退款状态
|
||||
* @see RefundStatusEnum
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/** 商户扩展参数,回调时会原样返回 */
|
||||
private String attach;
|
||||
|
||||
/** 错误码 */
|
||||
private String errorCode;
|
||||
|
||||
/** 错误原因 */
|
||||
private String errorMsg;
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
package org.dromara.daxpay.sdk.result.trade.pay;
|
||||
|
||||
import org.dromara.daxpay.sdk.code.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.dromara.daxpay.sdk.code.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
@@ -69,7 +69,7 @@ public class PaySignUtil {
|
||||
map.put(fieldName, datetime);
|
||||
}
|
||||
// map类型
|
||||
else if (Map.class.isAssignableFrom(field.getType())) {
|
||||
else if (Map.class.isAssignableFrom(field.getType()) || fieldValue instanceof Map) {
|
||||
Map<String, String> m = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
m.putAll((Map) fieldValue);
|
||||
map.put(fieldName, JsonUtil.toJsonStr(m));
|
||||
@@ -134,7 +134,6 @@ public class PaySignUtil {
|
||||
String s = content.toString();
|
||||
s = StrUtil.replace(s,"\\","");
|
||||
s = StrUtil.replace(s,"\"","");
|
||||
s = s.toUpperCase();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -22,6 +21,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
public class NoticeTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
|
||||
@Before
|
||||
@@ -31,9 +31,10 @@ public class NoticeTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.HMAC_SHA256)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8088873888246277")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,18 +43,8 @@ public class NoticeTest {
|
||||
@Test
|
||||
public void testNotice() {
|
||||
String json = "{\"noticeType\":\"pay\",\"mchNo\":\"M1723635576766\",\"appId\":\"M8088873888246277\",\"code\":0,\"msg\":\"success\",\"data\":{\"bizOrderNo\":\"20250221230917\",\"orderNo\":\"DEV_P2025022123091870000001\",\"title\":\"扫码支付\",\"allocation\":false,\"autoAllocation\":false,\"channel\":\"ali_pay\",\"method\":\"barcode\",\"amount\":0.01,\"refundableBalance\":0.01,\"status\":\"close\",\"refundStatus\":\"no_refund\",\"closeTime\":\"2025-02-21 23:40:00\",\"expiredTime\":\"2025-02-21 23:39:18\",\"errorMsg\":\"支付失败: 支付失败,获取顾客账户信息失败,请顾客刷新付款码后重新收款,如再次收款失败,请联系管理员处理。[SOUNDWAVE_PARSER_FAIL]\"},\"sign\":\"91ba428dc3a6ca17051d1835c8d24703cf2e10434acb337b0a43cc081f7fe45c\",\"resTime\":\"2025-04-10 23:45:42\",\"traceId\":\"BgSPIlOLsRBx\"}";
|
||||
DaxNoticeResult<PayOrderResult> bean = JsonUtil.toBean(json, new TypeReference<DaxNoticeResult<PayOrderResult>>() {
|
||||
/**
|
||||
* 获取用户定义的泛型参数
|
||||
*
|
||||
* @return 泛型参数
|
||||
*/
|
||||
@Override
|
||||
public Type getType() {
|
||||
return super.getType();
|
||||
}
|
||||
});
|
||||
boolean b = DaxPayKit.verifySign(bean);
|
||||
DaxNoticeResult<PayOrderResult> bean = JsonUtil.toBean(json, new TypeReference<DaxNoticeResult<PayOrderResult>>() {});
|
||||
boolean b = daxPayKit.verifySign(bean);
|
||||
System.out.println("验签结果: "+b);
|
||||
|
||||
// 转换成对象
|
||||
|
@@ -7,6 +7,7 @@ import org.dromara.daxpay.sdk.param.trade.pay.QueryPayParam;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.trade.pay.PayOrderResult;
|
||||
import org.dromara.daxpay.sdk.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -15,7 +16,9 @@ import org.junit.Test;
|
||||
* @author xxm
|
||||
* @since 2024/2/7
|
||||
*/
|
||||
@Slf4j
|
||||
public class QueryPayOrderTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -24,9 +27,10 @@ public class QueryPayOrderTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -36,8 +40,8 @@ public class QueryPayOrderTest {
|
||||
param.setOrderNo("DEV_P2025041010494470000002");
|
||||
param.setClientIp("127.0.0.1");
|
||||
|
||||
DaxResult<PayOrderResult> execute = DaxPayKit.execute(param);
|
||||
System.out.println("验签结果: " + DaxPayKit.verifySign(execute));
|
||||
DaxResult<PayOrderResult> execute = daxPayKit.execute(param);
|
||||
System.out.println("验签结果: " + daxPayKit.verifySign(execute));
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ import org.junit.Test;
|
||||
* @since 2024/2/7
|
||||
*/
|
||||
public class QueryRefundOrderTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -24,9 +25,10 @@ public class QueryRefundOrderTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -36,8 +38,8 @@ public class QueryRefundOrderTest {
|
||||
param.setRefundNo("DEV_R2025032911313670000021");
|
||||
param.setClientIp("127.0.0.1");
|
||||
|
||||
DaxResult<RefundOrderResult> execute = DaxPayKit.execute(param);
|
||||
System.out.println("验签结果: " + DaxPayKit.verifySign(execute));
|
||||
DaxResult<RefundOrderResult> execute = daxPayKit.execute(param);
|
||||
System.out.println("验签结果: " + daxPayKit.verifySign(execute));
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ import org.junit.Test;
|
||||
* @since 2025/4/7
|
||||
*/
|
||||
public class QueryTransferOrderTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
|
||||
@Before
|
||||
@@ -25,9 +26,10 @@ public class QueryTransferOrderTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,8 +39,8 @@ public class QueryTransferOrderTest {
|
||||
public void queryTransferOrder() {
|
||||
QueryTransferParam param = new QueryTransferParam();
|
||||
param.setTransferNo("DEV_T2025041111124570000021");
|
||||
DaxResult<TransferOrderResult> execute = DaxPayKit.execute(param);
|
||||
System.out.println("验签结果: " + DaxPayKit.verifySign(execute));
|
||||
DaxResult<TransferOrderResult> execute = daxPayKit.execute(param);
|
||||
System.out.println("验签结果: " + daxPayKit.verifySign(execute));
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import org.junit.Test;
|
||||
* @since 2024/2/5
|
||||
*/
|
||||
public class CloseOrderTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
|
||||
@Before
|
||||
@@ -24,9 +25,10 @@ public class CloseOrderTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +39,7 @@ public class CloseOrderTest {
|
||||
PayCloseParam param = new PayCloseParam();
|
||||
param.setOrderNo("DEVP24051019404463000001");
|
||||
param.setClientIp("127.0.0.1");
|
||||
DaxResult<Void> execute = DaxPayKit.execute(param);
|
||||
DaxResult<Void> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ public class CloseOrderTest {
|
||||
param.setOrderNo("DEV_P2025041017085370000011");
|
||||
param.setClientIp("127.0.0.1");
|
||||
param.setUseCancel(true);
|
||||
DaxResult<Void> execute = DaxPayKit.execute(param);
|
||||
DaxResult<Void> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,8 @@ import java.math.BigDecimal;
|
||||
* @since 2025/4/10
|
||||
*/
|
||||
public class GatewayPayTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
// 初始化支付配置
|
||||
@@ -28,9 +30,10 @@ public class GatewayPayTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,16 +47,15 @@ public class GatewayPayTest {
|
||||
param.setTitle("测试网关支付");
|
||||
param.setDescription("这是支付备注");
|
||||
param.setAmount(BigDecimal.valueOf(0.01));
|
||||
param.setGatewayPayType(GatewayPayTypeEnum.H5.getCode());
|
||||
param.setGatewayPayType(GatewayPayTypeEnum.PC.getCode());
|
||||
param.setAttach("{回调参数}");
|
||||
param.setAllocation(false);
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
DaxResult<GatewayPayUrlResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<GatewayPayUrlResult> execute = daxPayKit.execute(param);
|
||||
// 验签
|
||||
System.out.println("验签结果: " + DaxPayKit.verifySign(execute));
|
||||
System.out.println("验签结果: " + daxPayKit.verifySign(execute));
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,9 +74,9 @@ public class GatewayPayTest {
|
||||
param.setTerminalNo("66888");
|
||||
param.setAuthCode("66888");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
// 验签
|
||||
System.out.println("验签结果: " + DaxPayKit.verifySign(execute));
|
||||
System.out.println("验签结果: " + daxPayKit.verifySign(execute));
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -5,9 +5,9 @@ import org.dromara.daxpay.sdk.code.PayMethodEnum;
|
||||
import org.dromara.daxpay.sdk.code.SignTypeEnum;
|
||||
import org.dromara.daxpay.sdk.net.DaxPayConfig;
|
||||
import org.dromara.daxpay.sdk.net.DaxPayKit;
|
||||
import org.dromara.daxpay.sdk.param.channel.AdaPayParam;
|
||||
import org.dromara.daxpay.sdk.param.channel.AlipayParam;
|
||||
import org.dromara.daxpay.sdk.param.channel.WechatPayParam;
|
||||
import org.dromara.daxpay.sdk.param.channel.adapay.AdaPayParam;
|
||||
import org.dromara.daxpay.sdk.param.channel.alipay.AlipayParam;
|
||||
import org.dromara.daxpay.sdk.param.channel.wechat.WechatPayParam;
|
||||
import org.dromara.daxpay.sdk.param.trade.pay.PayParam;
|
||||
import org.dromara.daxpay.sdk.response.DaxResult;
|
||||
import org.dromara.daxpay.sdk.result.trade.pay.PayResult;
|
||||
@@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
||||
* @since 2024/2/5
|
||||
*/
|
||||
public class PayOrderTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -31,9 +32,10 @@ public class PayOrderTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,15 +49,15 @@ public class PayOrderTest {
|
||||
param.setTitle("测试微信扫码支付");
|
||||
param.setDescription("这是支付备注");
|
||||
param.setAmount(BigDecimal.valueOf(0.01));
|
||||
param.setChannel(ChannelEnum.WECHAT.getCode());
|
||||
param.setChannel(ChannelEnum.VBILL_PAY.getCode());
|
||||
param.setMethod(PayMethodEnum.QRCODE.getCode());
|
||||
param.setAttach("{回调参数}");
|
||||
param.setAllocation(false);
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
// 验签
|
||||
System.out.println("验签结果: " + DaxPayKit.verifySign(execute));
|
||||
System.out.println("验签结果: " + daxPayKit.verifySign(execute));
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -80,7 +82,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -106,7 +108,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -150,7 +152,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -165,14 +167,14 @@ public class PayOrderTest {
|
||||
param.setTitle("测试支付宝扫码支付");
|
||||
param.setDescription("这是支付宝扫码支付");
|
||||
param.setAmount(BigDecimal.valueOf(10));
|
||||
param.setChannel(ChannelEnum.ALIPAY.getCode());
|
||||
param.setChannel(ChannelEnum.ALIPAY_ISV.getCode());
|
||||
param.setMethod(PayMethodEnum.QRCODE.getCode());
|
||||
param.setAttach("{回调参数}");
|
||||
param.setAllocation(false);
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -200,7 +202,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -222,7 +224,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -237,14 +239,14 @@ public class PayOrderTest {
|
||||
param.setTitle("测试支付宝WEB支付");
|
||||
param.setDescription("这是支付宝WEB支付");
|
||||
param.setAmount(BigDecimal.valueOf(1.52));
|
||||
param.setChannel(ChannelEnum.ALIPAY.getCode());
|
||||
param.setMethod(PayMethodEnum.WEB.getCode());
|
||||
param.setChannel(ChannelEnum.ALIPAY_ISV.getCode());
|
||||
param.setMethod(PayMethodEnum.WAP.getCode());
|
||||
param.setAttach("{回调参数}");
|
||||
param.setAllocation(false);
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -272,7 +274,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -293,7 +295,7 @@ public class PayOrderTest {
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -315,13 +317,13 @@ public class PayOrderTest {
|
||||
param.setAttach("{回调参数}");
|
||||
param.setAllocation(false);
|
||||
AdaPayParam adaPayParam = new AdaPayParam();
|
||||
adaPayParam.setOpenId("9021000135649359");
|
||||
adaPayParam.setBuyerId("9021000135649359");
|
||||
param.setExtraParam(JsonUtil.toJsonStr(adaPayParam));
|
||||
|
||||
param.setReturnUrl("https://abc.com/returnurl");
|
||||
param.setNotifyUrl("http://127.0.0.1:19999/test/callback/notify");
|
||||
|
||||
DaxResult<PayResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<PayResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
|
||||
* @since 2024/2/5
|
||||
*/
|
||||
public class RefundOrderTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -29,9 +30,10 @@ public class RefundOrderTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,8 +48,8 @@ public class RefundOrderTest {
|
||||
param.setAttach("{回调参数}");
|
||||
param.setClientIp("127.0.0.1");
|
||||
|
||||
DaxResult<RefundResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<RefundResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
System.out.println(DaxPayKit.verifySign(execute));
|
||||
System.out.println(daxPayKit.verifySign(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import java.math.BigDecimal;
|
||||
* @since 2024/6/20
|
||||
*/
|
||||
public class TransferOrderTest {
|
||||
private DaxPayKit daxPayKit;
|
||||
|
||||
|
||||
@Before
|
||||
@@ -29,9 +30,10 @@ public class TransferOrderTest {
|
||||
.serviceUrl("http://127.0.0.1:19999")
|
||||
.signSecret("123456")
|
||||
.signType(SignTypeEnum.MD5)
|
||||
.mchNo("M1723635576766")
|
||||
.appId("M8207639754663343")
|
||||
.build();
|
||||
DaxPayKit.initConfig(config);
|
||||
this.daxPayKit = new DaxPayKit(config);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +54,8 @@ public class TransferOrderTest {
|
||||
// 使用OpenId
|
||||
param.setPayeeAccount("-G8AkkjjVhUl_VAf");
|
||||
// 发起请求
|
||||
DaxResult<TransferResult> execute = DaxPayKit.execute(param);
|
||||
System.out.println("验签: "+ DaxPayKit.verifySign(execute));
|
||||
DaxResult<TransferResult> execute = daxPayKit.execute(param);
|
||||
System.out.println("验签: "+ daxPayKit.verifySign(execute));
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
|
||||
@@ -74,7 +76,7 @@ public class TransferOrderTest {
|
||||
// 使用OpenId
|
||||
param.setPayeeAccount("");
|
||||
// 发起请求
|
||||
DaxResult<TransferResult> execute = DaxPayKit.execute(param);
|
||||
DaxResult<TransferResult> execute = daxPayKit.execute(param);
|
||||
System.out.println(JsonUtil.toJsonStr(execute));
|
||||
}
|
||||
}
|
||||
|
@@ -3,10 +3,11 @@ package org.dromara.daxpay.sdk.util;
|
||||
import org.dromara.daxpay.sdk.code.ChannelEnum;
|
||||
import org.dromara.daxpay.sdk.code.PayLimitPayEnum;
|
||||
import org.dromara.daxpay.sdk.code.PayMethodEnum;
|
||||
import org.dromara.daxpay.sdk.net.DaxPayKit;
|
||||
import org.dromara.daxpay.sdk.param.channel.WechatPayParam;
|
||||
import org.dromara.daxpay.sdk.param.channel.wechat.WechatPayParam;
|
||||
import org.dromara.daxpay.sdk.param.trade.pay.PayParam;
|
||||
import org.dromara.daxpay.sdk.response.DaxNoticeResult;
|
||||
import org.dromara.daxpay.sdk.result.trade.pay.PayOrderResult;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -51,9 +52,12 @@ public class ParamSignTest {
|
||||
log.info("参数: {}",JsonUtil.toJsonStr(param));
|
||||
Map<String, String> map = PaySignUtil.toMap(param);
|
||||
log.info("转换为有序MAP后的内容: {}",JsonUtil.toJsonStr(map));
|
||||
// " 和 \ 特殊符号过滤
|
||||
String data = PaySignUtil.createLinkString(map);
|
||||
log.info("将MAP拼接字符串, 并过滤掉特殊字符: {}",data);
|
||||
// 密钥为123456
|
||||
data = data+ "&key=123456";
|
||||
// 转大写
|
||||
data = data.toUpperCase();
|
||||
log.info("添加秘钥并转换为大写的字符串: {}",data);
|
||||
log.info("MD5: {}",PaySignUtil.md5(data));
|
||||
@@ -77,6 +81,7 @@ public class ParamSignTest {
|
||||
|
||||
Map<String, String> map = PaySignUtil.toMap(param);
|
||||
log.info("转换为有序MAP后的内容: {}",map);
|
||||
// " 和 \ 特殊符号过滤
|
||||
String data = PaySignUtil.createLinkString(map).replaceAll("\\\"","").replaceAll("\"","");
|
||||
log.info("将MAP拼接字符串, 并过滤掉特殊字符: {}",data);
|
||||
String sign = "123456";
|
||||
@@ -87,27 +92,46 @@ public class ParamSignTest {
|
||||
log.info("HmacSHA256: {}",PaySignUtil.hmacSha256(data,sign));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验签测试
|
||||
* 响应结果和回调结果验签
|
||||
*/
|
||||
@Test
|
||||
public void verifySign(){
|
||||
String json = "{\"noticeType\":\"pay\",\"mchNo\":\"M1723635576766\",\"appId\":\"M8088873888246277\",\"code\":0,\"msg\":\"success\",\"data\":{\"bizOrderNo\":\"20250221230917\",\"orderNo\":\"DEV_P2025022123091870000001\",\"title\":\"扫码支付\",\"allocation\":false,\"autoAllocation\":false,\"channel\":\"ali_pay\",\"method\":\"barcode\",\"amount\":0.01,\"refundableBalance\":0.01,\"status\":\"close\",\"refundStatus\":\"no_refund\",\"closeTime\":\"2025-02-21 23:40:00\",\"expiredTime\":\"2025-02-21 23:39:18\",\"errorMsg\":\"支付失败: 支付失败,获取顾客账户信息失败,请顾客刷新付款码后重新收款,如再次收款失败,请联系管理员处理。[SOUNDWAVE_PARSER_FAIL]\"},\"sign\":\"91ba428dc3a6ca17051d1835c8d24703cf2e10434acb337b0a43cc081f7fe45c\",\"resTime\":\"2025-04-10 23:45:42\",\"traceId\":\"BgSPIlOLsRBx\"}";
|
||||
DaxNoticeResult<?> bean = JsonUtil.toBean(json, DaxNoticeResult.class);
|
||||
boolean b = DaxPayKit.verifySign(bean);
|
||||
System.out.println("验签结果: "+b);
|
||||
|
||||
log.info("参数: {}",JsonUtil.toJsonStr(bean));
|
||||
Map<String, String> map = PaySignUtil.toMap(bean);
|
||||
map.remove("sign");
|
||||
log.info("转换为有序MAP后的内容: {}",JsonUtil.toJsonStr(map));
|
||||
String data = PaySignUtil.createLinkString(map);
|
||||
log.info("将MAP拼接字符串, 并过滤掉特殊字符: {}",data);
|
||||
data = data+ "&key=123456";
|
||||
data = data.toUpperCase();
|
||||
log.info("添加秘钥并转换为大写的字符串: {}",data);
|
||||
log.info("hmacSha256: {}",PaySignUtil.hmacSha256(data, "123456"));
|
||||
|
||||
public void callbackAndVerifySign(){
|
||||
String data = "{\n" +
|
||||
" \"mchNo\" : \"M1745845174843\",\n" +
|
||||
" \"appId\" : \"A0646259306964009\",\n" +
|
||||
" \"code\" : 0,\n" +
|
||||
" \"msg\" : \"success\",\n" +
|
||||
" \"data\" : {\n" +
|
||||
" \"bizOrderNo\" : \"PAY_492854192101747473544745\",\n" +
|
||||
" \"orderNo\" : \"DEV_P2025051717190770000003\",\n" +
|
||||
" \"title\" : \"测试支付\",\n" +
|
||||
" \"allocation\" : false,\n" +
|
||||
" \"autoAllocation\" : false,\n" +
|
||||
" \"channel\" : \"alipay_isv\",\n" +
|
||||
" \"method\" : \"other\",\n" +
|
||||
" \"otherMethod\" : \"WX_JSAPI\",\n" +
|
||||
" \"amount\" : 0.01,\n" +
|
||||
" \"refundableBalance\" : 0.01,\n" +
|
||||
" \"status\" : \"close\",\n" +
|
||||
" \"refundStatus\" : \"no_refund\",\n" +
|
||||
" \"closeTime\" : \"2025-05-18 10:14:14\",\n" +
|
||||
" \"expiredTime\" : \"2025-05-17 21:41:28\"\n" +
|
||||
" },\n" +
|
||||
" \"sign\" : \"86604c1eb66dc3ef22de28be09d993cb91eb46bcd77ee51b0142240ae7ba50fe\",\n" +
|
||||
" \"resTime\" : \"2025-06-05 17:46:54\",\n" +
|
||||
" \"traceId\" : \"nu2Pezn0FvKd\"\n" +
|
||||
"}";
|
||||
log.info("notify/callback:{}",data);
|
||||
// 转换成实体类, 使用sdk中内置的json工具类转换
|
||||
DaxNoticeResult<PayOrderResult> x = JsonUtil.toBean(data, new TypeReference<DaxNoticeResult<PayOrderResult>>() {});
|
||||
boolean s1 = PaySignUtil.verifyHmacSha256Sign(x, "bc5b5d592cc34434a27fb57fe923dacc5374da52a4174ff5874768a8215e5fd3", x.getSign());
|
||||
log.info("验签结果: {}",s1);
|
||||
// 使用map方式验签
|
||||
DaxNoticeResult<Map<String,Object>> bean = JsonUtil.toBean(data, new TypeReference<DaxNoticeResult<Map<String,Object>>>() {});
|
||||
boolean s2 = PaySignUtil.verifyHmacSha256Sign(bean, "bc5b5d592cc34434a27fb57fe923dacc5374da52a4174ff5874768a8215e5fd3", bean.getSign());
|
||||
log.info("验签结果: {}",s2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,15 +5,15 @@ spring:
|
||||
datasource:
|
||||
master:
|
||||
# Postgresql连接
|
||||
driver-class-name: org.postgresql.Driver
|
||||
url: jdbc:postgresql://${DB_HOST:postgresql}:${DB_PORT:5432}/dax-pay-dev?serverTimezone=Asia/Shanghai&autoReconnect=true&reWriteBatchedInserts=true
|
||||
username: ${DB_USER:bootx}
|
||||
password: ${DB_PASSWORD:bootx123}
|
||||
# MySQL连接
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://${DB_HOST:mysql}:${DB_PORT:3306}/dax-pay-dev?serverTimezone=GMT%2B8&characterEncoding=utf8&allowMultiQueries=true&useSSL=false&nullCatalogMeansCurrent=true
|
||||
# username: ${DB_USER:root}
|
||||
# driver-class-name: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://${DB_HOST:postgresql}:${DB_PORT:5432}/dax-pay-dev?serverTimezone=Asia/Shanghai&autoReconnect=true&reWriteBatchedInserts=true
|
||||
# username: ${DB_USER:bootx}
|
||||
# password: ${DB_PASSWORD:bootx123}
|
||||
# MySQL连接
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://${DB_HOST:mysql}:${DB_PORT:3306}/dax-pay-open?serverTimezone=GMT%2B8&characterEncoding=utf8&allowMultiQueries=true&useSSL=false&nullCatalogMeansCurrent=true
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PASSWORD:bootx123}
|
||||
hikari:
|
||||
minimumIdle: 5 # 最小连接数
|
||||
maximumPoolSize: 50 # 最大连接数
|
||||
|
@@ -1,7 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
daxpay-single:
|
||||
image: daxpay/daxpay-single:3.0.0
|
||||
image: daxpay/daxpay-open:3.0.0
|
||||
restart: always
|
||||
# window上不支持host网络模式, 需要更改为 bridge 网络模式, 然后走端口映射
|
||||
network_mode: host
|
||||
@@ -12,9 +12,7 @@ services:
|
||||
# 读取外部化配置文件(根据实际服务器环境做修改), 宿主机目录:容器目录
|
||||
volumes:
|
||||
# 日志
|
||||
- ./data/logs/:/logs
|
||||
# 上传文件目录
|
||||
- ./data/files/:/data/files
|
||||
- ./logs/:/logs
|
||||
environment:
|
||||
# pgsql数据库连接地址
|
||||
- DB_URL=jdbc:pgsql://127.0.0.1:3306/dax-pay-single?serverTimezone=GMT%2B8&characterEncoding=utf8&allowMultiQueries=true&useSSL=false&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
|
||||
|
Reference in New Issue
Block a user