feat SDK增加简单退款、多通道退款等多中测试样例

This commit is contained in:
xxm1995
2024-02-26 13:45:09 +08:00
parent 9126d167c6
commit fabea44a7b
3 changed files with 125 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
package cn.bootx.platform.daxpay.sdk.param.channel;
import cn.bootx.platform.daxpay.sdk.param.ChannelParam;
import lombok.Getter;
import lombok.Setter;
/**
* 付款码支付
* @author xxm
* @since 2024/2/26
*/
@Getter
@Setter
public class BarCodePayParam implements ChannelParam {
/** 授权码(主动扫描用户的付款码) */
private String authCode;
}

View File

@@ -1,5 +1,6 @@
package cn.bootx.platform.daxpay.sdk.payment;
import cn.bootx.platform.daxpay.sdk.code.PayChannelEnum;
import cn.bootx.platform.daxpay.sdk.model.refund.RefundModel;
import cn.bootx.platform.daxpay.sdk.net.DaxPayConfig;
import cn.bootx.platform.daxpay.sdk.net.DaxPayKit;
@@ -9,6 +10,7 @@ import cn.bootx.platform.daxpay.sdk.response.DaxPayResult;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -63,7 +65,7 @@ public class RefundOrderTest {
// 设置具体的退款参数
RefundChannelParam refundChannelParam = new RefundChannelParam();
refundChannelParam.setChannel("ali_pay");
refundChannelParam.setChannel(PayChannelEnum.ALI.getCode());
refundChannelParam.setAmount(12);
List<RefundChannelParam> refundChannels = Collections.singletonList(refundChannelParam);
param.setRefundChannels(refundChannels);
@@ -72,4 +74,41 @@ public class RefundOrderTest {
System.out.println(execute);
System.out.println(execute.getData());
}
/**
* 多通道退款
*/
@Test
public void refundOrderByMultiple(){
RefundParam param = new RefundParam();
param.setClientIp("127.0.0.1");
param.setBusinessNo("P0001");
param.setRefundAll(false);
param.setRefundNo("R0001");
// 设置具体的退款参数
RefundChannelParam alipay = new RefundChannelParam();
// 支付宝
alipay.setChannel(PayChannelEnum.ALI.getCode());
alipay.setAmount(12);
// 钱包
RefundChannelParam wallet = new RefundChannelParam();
alipay.setChannel(PayChannelEnum.WALLET.getCode());
alipay.setAmount(10);
// 现金
RefundChannelParam cash = new RefundChannelParam();
alipay.setChannel(PayChannelEnum.CASH.getCode());
alipay.setAmount(20);
List<RefundChannelParam> refundChannels = Arrays.asList(alipay, wallet, cash);
param.setRefundChannels(refundChannels);
DaxPayResult<RefundModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
System.out.println(execute.getData());
}
}

View File

@@ -0,0 +1,67 @@
package cn.bootx.platform.daxpay.sdk.payment;
import cn.bootx.platform.daxpay.sdk.model.refund.RefundModel;
import cn.bootx.platform.daxpay.sdk.net.DaxPayConfig;
import cn.bootx.platform.daxpay.sdk.net.DaxPayKit;
import cn.bootx.platform.daxpay.sdk.param.refund.SimpleRefundParam;
import cn.bootx.platform.daxpay.sdk.response.DaxPayResult;
import org.junit.Before;
import org.junit.Test;
/**
* 简单退款演示
* @author xxm
* @since 2024/2/26
*/
public class SimpleRefundOrderTest {
/**
* 初始化
*/
@Before
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:9000")
.signSecret("123456")
.build();
DaxPayKit.initConfig(config);
}
/**
* 全部退款
*/
@Test
public void refundAllOrder(){
SimpleRefundParam param = new SimpleRefundParam();
param.setClientIp("127.0.0.1");
param.setBusinessNo("P0001");
param.setRefundNo("R0001");
param.setRefundAll(true);
DaxPayResult<RefundModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
System.out.println(execute.getData());
}
/**
* 部分退款
*/
@Test
public void refundPartOrder(){
SimpleRefundParam param = new SimpleRefundParam();
param.setClientIp("127.0.0.1");
param.setBusinessNo("P0001");
param.setRefundAll(false);
param.setRefundNo("R0001");
// 设置具体的退款参数
param.setAmount(1);
DaxPayResult<RefundModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
System.out.println(execute.getData());
}
}