Skip to content

Commit

Permalink
ref 调整查询和回调通知接口
Browse files Browse the repository at this point in the history
  • Loading branch information
xxm1995 committed May 16, 2024
1 parent fdbdd42 commit 9699661
Show file tree
Hide file tree
Showing 26 changed files with 358 additions and 119 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

## 📃 文档和源码地址
### 文档地址
[Bootx开源文档站](https://doc.bootx.cn/) 下的支付网关(DaxPay)模块下可以进行查阅相关文档,具体链接地址如下:
[快速指南](https://doc.bootx.cn/daxpay/guides/overview/项目介绍.html)
[支付对接](https://doc.bootx.cn/daxpay/gateway/overview/接口清单.html)
[操作手册](https://doc.bootx.cn/daxpay/admin/config/平台配置.html)
[DaxPay文档站](https://doc.daxpay.cn/) 下的支付网关(DaxPay)模块下可以进行查阅相关文档,具体链接地址如下:
[快速指南](https://doc.daxpay.cn/single/guides/overview/项目介绍.html)
[支付对接](https://doc.daxpay.cn/single/gateway/overview/接口清单.html)
[操作手册](https://doc.daxpay.cn/single/admin/config/平台配置.html)

### 项目地址

Expand Down Expand Up @@ -89,7 +89,7 @@
不会对原业务系统的架构产生影响。如果是Java项目,可以使用SDK简化接入流程, 其他语言可以参照中的说明使用HTTP接口方式接入。

### Java客户端SDK
> SDK版本号与支付网关的版本保持一致,如果需要使用,请在pom.xml中添加如下依赖。SDK使用方式参考[SDK使用说明](https://doc.bootx.cn/daxpay/gateway/overview/SDK使用说明.html)
> SDK版本号与支付网关的版本保持一致,如果需要使用,请在pom.xml中添加如下依赖。SDK使用方式参考[SDK使用说明](https://doc.daxpay.cn/single/gateway/overview/SDK使用说明.html)
```xml
<!-- 支付SDK -->
Expand All @@ -100,7 +100,7 @@
</dependency>
```
### SDK调用示例
> 此处以支付接口为例,演示业务系统如何调用支付网关进行支付,其他接口的调用方式类似,具体请参考[支付对接](https://doc.bootx.cn/daxpay/gateway/overview/接口清单.html)
> 此处以支付接口为例,演示业务系统如何调用支付网关进行支付,其他接口的调用方式类似,具体请参考[支付对接](https://doc.daxpay.cn/single/gateway/overview/接口清单.html)
```java
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package cn.daxpay.single.demo.controller;

import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import cn.daxpay.single.demo.configuration.DaxPayDemoProperties;
import cn.daxpay.single.sdk.model.notice.PayNoticeModel;
import cn.daxpay.single.sdk.model.notice.RefundNoticeModel;
import cn.daxpay.single.sdk.util.PaySignUtil;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
Expand All @@ -26,11 +29,15 @@
@RequestMapping("/demo/callback")
@RequiredArgsConstructor
public class ClientNoticeReceiveController {
private final DaxPayDemoProperties daxPayDemoProperties;

@Operation(summary = "支付消息(map接收)")
@PostMapping("/pay")
public String pay(@RequestBody Map<String,Object> map){
log.info("接收到支付回调消息: {}",map);
// 转换为对象
PayNoticeModel bean = BeanUtil.toBean(map, PayNoticeModel.class);
log.info("验签结果: {}", PaySignUtil.hmacSha256Sign(bean, daxPayDemoProperties.getSignSecret()));
return "SUCCESS";
}

Expand All @@ -39,20 +46,25 @@ public String pay(@RequestBody Map<String,Object> map){
@PostMapping("/payObject")
public String pay(@RequestBody PayNoticeModel model){
log.info("接收到支付回调消息: {}",model);
log.info("验签结果: {}", PaySignUtil.hmacSha256Sign(model, daxPayDemoProperties.getSignSecret()));
return "SUCCESS";
}

@Operation(summary = "退款消息")
@PostMapping("/refund")
public String refund(@RequestBody Map<String,Object> map) {
log.info("接收到退款回调消息: {}",map);
// 转换为对象
RefundNoticeModel model = BeanUtil.toBean(map, RefundNoticeModel.class);
log.info("验签结果: {}", PaySignUtil.hmacSha256Sign(model, daxPayDemoProperties.getSignSecret()));
return "SUCCESS";
}

@Operation(summary = "退款消息(对象)")
@PostMapping("/refundObject")
public String refund(@RequestBody RefundNoticeModel map) {
log.info("接收到退款回调消息: {}",map);
public String refund(@RequestBody RefundNoticeModel model) {
log.info("接收到退款回调消息: {}",model);
log.info("验签结果: {}", PaySignUtil.hmacSha256Sign(model, daxPayDemoProperties.getSignSecret()));
return "SUCCESS";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cn.daxpay.single.sdk.code;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* 支付订单分账状态
* @author xxm
* @since 2024/4/16
*/
@Getter
@AllArgsConstructor
public enum PayOrderAllocStatusEnum {
WAITING("waiting", "待分账"),
ALLOCATION("allocation", "已分账"),
;

final String code;
final String name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.PayStatusEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand All @@ -14,7 +15,7 @@
@Getter
@Setter
@ToString
public class PayNoticeModel {
public class PayNoticeModel extends DaxPayResponseModel {

/** 订单号 */
private String orderNo;
Expand Down Expand Up @@ -55,7 +56,10 @@ public class PayNoticeModel {
/** 商户扩展参数,回调时会原样返回 */
private String attach;

/** 签名 */
private String sign;
/** 错误码 */
private String errorCode;

/** 错误原因 */
private String errorMsg;

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.RefundStatusEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand All @@ -14,7 +15,7 @@
@Getter
@Setter
@ToString
public class RefundNoticeModel {
public class RefundNoticeModel extends DaxPayResponseModel {

/** 退款号 */
private String refundNo;
Expand Down Expand Up @@ -46,6 +47,9 @@ public class RefundNoticeModel {
/** 商户扩展参数,回调时会原样返回 */
private String attach;

/** 签名 */
private String sign;
/** 错误码 */
private String errorCode;

/** 错误原因 */
private String errorMsg;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.daxpay.single.sdk.model.pay;

import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.PayOrderAllocStatusEnum;
import cn.daxpay.single.sdk.code.PayStatusEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
Expand All @@ -17,18 +18,30 @@
@ToString
public class PayOrderModel extends DaxPayResponseModel {

/** 支付订单号 */

/** 订单号 */
private String orderNo;

/** 业务系统订单号 */
/** 商户订单号 */
private String bizOrderNo;

/** 通道系统交易号 */
private String outOrderNo;

/** 标题 */
private String title;

/** 描述 */
private String description;


/** 是否支持分账 */
private Boolean allocation;

/** 是否开启自动分账, 不传输为不开启 */
private Boolean autoAllocation;


/**
* 支付通道
* @see PayChannelEnum
Expand All @@ -52,6 +65,13 @@ public class PayOrderModel extends DaxPayResponseModel {
*/
private String status;

/**
* 分账状态
* @see PayOrderAllocStatusEnum
*/
private String allocationStatus;


/** 支付时间 */
private Long payTime;

Expand All @@ -60,4 +80,10 @@ public class PayOrderModel extends DaxPayResponseModel {

/** 关闭时间 */
private Long closeTime;

/** 错误码 */
private String errorCode;

/** 错误信息 */
private String errorMsg;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.daxpay.single.sdk.model.refund;

import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.RefundStatusEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
Expand All @@ -18,27 +19,58 @@
@ToString
public class RefundOrderModel extends DaxPayResponseModel {


/** 支付订单号 */
private String orderNo;

/** 商户支付订单号 */
private String bizOrderNo;

/** 通道支付订单号 */
private String outOrderNo;

/** 支付标题 */
private String title;

/** 退款号 */
private String refundNo;

/** 商户退款号 */
private String bizRefundNo;

/** 标题 */
private String title;
/** 通道退款交易号 */
private String outRefundNo;

/**
* 退款通道
* @see PayChannelEnum
*/
private String channel;

/** 订单金额 */
private Integer orderAmount;

/** 退款金额 */
private BigDecimal amount;

/** 退款完成时间 */
private Long finishTime;
/** 退款原因 */
private String reason;

/** 退款发起时间 */
private Long refundTime;

/** 退款完成时间 */
private Long finishTime;

/**
* 退款状态
* @see RefundStatusEnum
*/
private String status;

/** 错误码 */
private String errorCode;

/** 错误信息 */
private String errorMsg;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class QueryPayParam extends DaxPayRequest<PayOrderModel> {
*/
@Override
public String path() {
return "/uni/query/payOrder";
return "/unipay/query/payOrder";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class QueryRefundParam extends DaxPayRequest<RefundOrderModel> {
*/
@Override
public String path() {
return "/uni/query/refundOrder";
return "/unipay/query/refundOrder";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public void init() {
public void testPay() {
QueryPayParam param = new QueryPayParam();

param.setBizOrderNoeNo("2");
param.setBizOrderNoeNo("P17141882417921");
param.setClientIp("127.0.0.1");

DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ public void init() {
}

@Test
public void testPay() {
public void testRefund() {
QueryRefundParam param = new QueryRefundParam();

param.setBizRefundNo("1755263825769361408");
param.setRefundNo("DEVR24051020531763000014");
param.setClientIp("127.0.0.1");

DaxPayResult<RefundOrderModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
Expand Down
Loading

0 comments on commit 9699661

Please sign in to comment.