diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java
index 68eac48cb..e089abc4c 100644
--- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java
+++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant;
-import cn.iocoder.yudao.framework.sms.core.enums.PayChannelCodeEnum;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import lombok.Data;
@@ -23,7 +23,7 @@ public class PayChannelDO extends BaseDO {
/**
* 渠道编码
*
- * 枚举 {@link PayChannelCodeEnum}
+ * 枚举 {@link PayChannelEnum}
*/
private String code;
/**
diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java
index ebdc26030..1bcb8eaf7 100644
--- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java
+++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order;
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
-import cn.iocoder.yudao.framework.sms.core.enums.PayChannelCodeEnum;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -49,7 +49,7 @@ public class PayOrderDO extends BaseDO {
/**
* 渠道编码
*
- * 枚举 {@link PayChannelCodeEnum}
+ * 枚举 {@link PayChannelEnum}
*/
private String channelCode;
diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java
index 732b68b13..cf526ec16 100644
--- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java
+++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order;
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
-import cn.iocoder.yudao.framework.sms.core.enums.PayChannelCodeEnum;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import lombok.Data;
@@ -51,7 +51,7 @@ public class PayRefundDO extends BaseDO {
/**
* 商户编码
*
- * 枚举 {@link PayChannelCodeEnum}
+ * 枚举 {@link PayChannelEnum}
*/
private String channelCode;
/**
diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/PayChannelCodeEnum.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/PayChannelCodeEnum.java
deleted file mode 100644
index 095692a2b..000000000
--- a/yudao-core-service/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/PayChannelCodeEnum.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.iocoder.yudao.framework.sms.core.enums;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * 支付渠道的编码的枚举
- *
- * @author 芋道源码
- */
-@Getter
-@AllArgsConstructor
-public enum PayChannelCodeEnum {
-
- wx_pub("wx_pub", "微信 JSAPI 支付");
-
- /**
- * 编码
- *
- * 参考 https://www.pingxx.com/api/支付渠道属性值.html
- */
- private String code;
- /**
- * 名字
- */
- private String name;
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml
index 668ce5d3d..16b8b9368 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml
@@ -68,5 +68,12 @@
4.1.9.B
+
+
+
+ cn.iocoder.boot
+ yudao-spring-boot-starter-test
+ test
+
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java
index b3f978fc9..f6d0ca6b5 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java
@@ -22,6 +22,7 @@ public interface PayClientFactory {
* @param channelCode 渠道编码
* @param config 支付配置
*/
- void createOrUpdatePayClient(Long channelId, String channelCode, PayClientConfig config);
+ void createOrUpdatePayClient(Long channelId, String channelCode,
+ Config config);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java
index d8f9d97c5..16cc49ed2 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java
@@ -1,8 +1,16 @@
package cn.iocoder.yudao.framework.pay.core.client.impl;
+import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory;
+import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
+import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient;
+import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient;
+import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
+import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
+import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -12,22 +20,52 @@ import java.util.concurrent.ConcurrentMap;
*
* @author 芋道源码
*/
+@Slf4j
public class PayClientFactoryImpl implements PayClientFactory {
/**
* 支付客户端 Map
* key:渠道编号
*/
- private final ConcurrentMap channelIdClients = new ConcurrentHashMap<>();
+ private final ConcurrentMap> channelIdClients = new ConcurrentHashMap<>();
@Override
public PayClient getPayClient(Long channelId) {
- return null;
+ AbstractPayClient> client = channelIdClients.get(channelId);
+ if (client == null) {
+ log.error("[getPayClient][渠道编号({}) 找不到客户端]", channelId);
+ }
+ return client;
}
@Override
- public void createOrUpdatePayClient(Long channelId, String channelCode, PayClientConfig config) {
+ @SuppressWarnings("unchecked")
+ public void createOrUpdatePayClient(Long channelId, String channelCode,
+ Config config) {
+ AbstractPayClient client = (AbstractPayClient) channelIdClients.get(channelId);
+ if (client == null) {
+ client = this.createPayClient(channelId, channelCode, config);
+ client.init();
+ channelIdClients.put(client.getId(), client);
+ } else {
+ client.refresh(config);
+ }
+ }
+ @SuppressWarnings("unchecked")
+ private AbstractPayClient createPayClient(
+ Long channelId, String channelCode, Config config) {
+ PayChannelEnum channelEnum = PayChannelEnum.getByCode(channelCode);
+ Assert.notNull(channelEnum, String.format("支付渠道(%s) 为空", channelEnum));
+ // 创建客户端
+ switch (channelEnum) {
+ case WX_PUB: return (AbstractPayClient) new WXPubPayClient(channelId, (WXPayClientConfig) config);
+ case ALIPAY_WAP: return (AbstractPayClient) new AlipayWapPayClient(channelId, (AlipayPayClientConfig) config);
+ case ALIPAY_QR: return (AbstractPayClient) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config);
+ }
+ // 创建失败,错误日志 + 抛出异常
+ log.error("[createSmsClient][配置({}) 找不到合适的客户端实现]", config);
+ throw new IllegalArgumentException(String.format("配置(%s) 找不到合适的客户端实现", config));
}
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java
index 16ded752e..8cafd425d 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java
@@ -1,8 +1,11 @@
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.framework.pay.core.client.AbstractPayCodeMapping;
+import java.util.Objects;
+
/**
* 支付宝的 PayCodeMapping 实现类
*
@@ -12,6 +15,9 @@ public class AlipayPayCodeMapping extends AbstractPayCodeMapping {
@Override
protected ErrorCode apply0(String apiCode, String apiMsg) {
+ if (Objects.equals(apiCode, "10000")) {
+ return GlobalErrorCodeConstants.SUCCESS;
+ }
return null;
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java
index 58473185d..c1d6f691a 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.pay.core.client.PayCommonResult;
import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO;
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
@@ -27,8 +28,8 @@ public class AlipayQrPayClient extends AbstractPayClient
private DefaultAlipayClient client;
- public AlipayQrPayClient(Long channelId, String channelCode, AlipayPayClientConfig config) {
- super(channelId, channelCode, config, new AlipayPayCodeMapping());
+ public AlipayQrPayClient(Long channelId, AlipayPayClientConfig config) {
+ super(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config, new AlipayPayCodeMapping());
}
@Override
@@ -61,29 +62,8 @@ public class AlipayQrPayClient extends AbstractPayClient
log.error("[unifiedOrder][request({}) 发起支付失败]", toJsonString(reqDTO), e);
return PayCommonResult.build(e.getErrCode(), e.getErrMsg(), null, codeMapping);
}
-
- System.out.println(response.getBody());
- System.out.println(response.getQrCode());
-
- // TODO 芋艿:sub Code
+ // TODO 芋艿:sub Code 需要测试下各种失败的情况
return PayCommonResult.build(response.getCode(), response.getMsg(), response, codeMapping);
}
- public static void main(String[] args) {
- AlipayPayClientConfig config = new AlipayPayClientConfig();
- config.setAppId("2021000118634035");
- config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX);
- config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT);
- config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybV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jANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB");
- AlipayQrPayClient client = new AlipayQrPayClient(1L, "biu", config);
- client.init();
-
- PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO();
- reqDTO.setAmount(123);
- reqDTO.setSubject("IPhone 13");
- reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis()));
- client.unifiedOrder(reqDTO);
- }
-
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java
index b89d1208b..15fd5fb75 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.pay.core.client.PayCommonResult;
import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO;
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
@@ -23,8 +24,8 @@ public class AlipayWapPayClient extends AbstractPayClient
private DefaultAlipayClient client;
- public AlipayWapPayClient(Long channelId, String channelCode, AlipayPayClientConfig config) {
- super(channelId, channelCode, config, new AlipayPayCodeMapping());
+ public AlipayWapPayClient(Long channelId, AlipayPayClientConfig config) {
+ super(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config, new AlipayPayCodeMapping());
}
@Override
@@ -57,29 +58,8 @@ public class AlipayWapPayClient extends AbstractPayClient
} catch (AlipayApiException e) {
return PayCommonResult.build(e.getErrCode(), e.getErrMsg(), null, codeMapping);
}
-
- System.out.println(response.getBody());
-
// TODO 芋艿:sub Code
return PayCommonResult.build(response.getCode(), response.getMsg(), response, codeMapping);
}
- public static void main(String[] args) {
- AlipayPayClientConfig config = new AlipayPayClientConfig();
- config.setAppId("2021000118634035");
- config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX);
- config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT);
- config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdk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pN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8=");
- config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB");
- AlipayWapPayClient client = new AlipayWapPayClient(1L, "biubiubiu", config);
- client.init();
-
- PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO();
- reqDTO.setAmount(123);
- reqDTO.setSubject("IPhone 13");
- reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis()));
- client.unifiedOrder(reqDTO);
- }
-
-
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/index.html b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/index.html
deleted file mode 100644
index 601a6b2cc..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java
index cb0bce6fb..5d8f042eb 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java
@@ -2,13 +2,13 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.wx;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
import cn.iocoder.yudao.framework.pay.core.client.PayCommonResult;
import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO;
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
@@ -21,9 +21,6 @@ import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import lombok.extern.slf4j.Slf4j;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
import static cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXCodeMapping.CODE_SUCCESS;
@@ -39,8 +36,8 @@ public class WXPubPayClient extends AbstractPayClient {
private WxPayService client;
- public WXPubPayClient(Long channelId, String channelCode, WXPayClientConfig config) {
- super(channelId, channelCode, config, new WXCodeMapping());
+ public WXPubPayClient(Long channelId, WXPayClientConfig config) {
+ super(channelId, PayChannelEnum.WX_PUB.getCode(), config, new WXCodeMapping());
}
@Override
@@ -120,29 +117,4 @@ public class WXPubPayClient extends AbstractPayClient {
return client.createOrderV3(TradeTypeEnum.JSAPI, request);
}
- public static void main(String[] args) throws FileNotFoundException {
- WXPayClientConfig config = new WXPayClientConfig();
- config.setAppId("wx041349c6f39b268b");
- config.setMchId("1545083881");
- config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p");
- config.setApiVersion(WXPayClientConfig.API_VERSION_V3);
-// config.setKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.p12")));
- config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem")));
- config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem")));
- config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase");
-
- WXPubPayClient client = new WXPubPayClient(1L, "biu", config);
- client.init();
-
- PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO();
- reqDTO.setAmount(123);
- reqDTO.setSubject("IPhone 13");
- reqDTO.setBody("biubiubiu");
- reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis()));
- reqDTO.setClientIp("127.0.0.1");
- reqDTO.setNotifyUrl("http://127.0.0.1:8080");
- CommonResult result = client.unifiedOrder(reqDTO);
- System.out.println(result);
- }
-
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java
new file mode 100644
index 000000000..ed1389e0e
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java
@@ -0,0 +1,41 @@
+package cn.iocoder.yudao.framework.pay.core.enums;
+
+import cn.hutool.core.util.ArrayUtil;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 支付渠道的编码的枚举
+ * 枚举值
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum PayChannelEnum {
+
+ WX_PUB("wx_pub", "微信 JSAPI 支付"), // 公众号的网页
+ WX_LITE("wx_lit","微信小程序支付"),
+ WX_APP("wx_app", "微信 App 支付"),
+
+ ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付"),
+ ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付"),
+ ALIPAY_APP("alipay_app", "支付宝App 支付"),
+ ALIPAY_QR("alipay_qr", "支付宝扫码支付");
+
+ /**
+ * 编码
+ *
+ * 参考 https://www.pingxx.com/api/支付渠道属性值.html
+ */
+ private String code;
+ /**
+ * 名字
+ */
+ private String name;
+
+ public static PayChannelEnum getByCode(String code) {
+ return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
+ }
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/package-info.java
deleted file mode 100644
index 9b1175ee7..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * @description
- * @author Qingchen
- * @version 1.0.0
- * @date 2021-09-29 14:33
- * @class cn.iocoder.yudao.framework.pay.package-info.java
- */
-package cn.iocoder.yudao.framework.pay;
\ No newline at end of file
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java
new file mode 100644
index 000000000..e5ccbe836
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java
@@ -0,0 +1,129 @@
+package cn.iocoder.yudao.framework.core.client.impl;
+
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.RandomUtil;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import cn.iocoder.yudao.framework.pay.core.client.PayClient;
+import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO;
+import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl;
+import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
+import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient;
+import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient;
+import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
+import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient;
+import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
+import org.junit.jupiter.api.Test;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/**
+ * {@link PayClientFactoryImpl} 的集成测试
+ *
+ * @author 芋道源码
+ */
+public class PayClientFactoryImplTest {
+
+ private final PayClientFactoryImpl payClientFactory = new PayClientFactoryImpl();
+
+ /**
+ * {@link WXPubPayClient} 的 V2 版本
+ */
+ @Test
+ public void testCreatePayClient_WX_PUB_V2() {
+ // 创建配置
+ WXPayClientConfig config = new WXPayClientConfig();
+ config.setAppId("wx041349c6f39b268b");
+ config.setMchId("1545083881");
+ config.setApiVersion(WXPayClientConfig.API_VERSION_V2);
+ config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p");
+ // 创建客户端
+ Long channelId = RandomUtil.randomLong();
+ payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config);
+ PayClient client = payClientFactory.getPayClient(channelId);
+ // 发起支付
+ PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO();
+ CommonResult> result = client.unifiedOrder(reqDTO);
+ System.out.println(result);
+ }
+
+ /**
+ * {@link WXPubPayClient} 的 V3 版本
+ */
+ @Test
+ public void testCreatePayClient_WX_PUB_V3() throws FileNotFoundException {
+ // 创建配置
+ WXPayClientConfig config = new WXPayClientConfig();
+ config.setAppId("wx041349c6f39b268b");
+ config.setMchId("1545083881");
+ config.setApiVersion(WXPayClientConfig.API_VERSION_V3);
+ config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem")));
+ config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem")));
+ config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase");
+ // 创建客户端
+ Long channelId = RandomUtil.randomLong();
+ payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config);
+ PayClient client = payClientFactory.getPayClient(channelId);
+ // 发起支付
+ PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO();
+ CommonResult> result = client.unifiedOrder(reqDTO);
+ System.out.println(result);
+ }
+
+ /**
+ * {@link AlipayQrPayClient}
+ */
+ @Test
+ public void testCreatePayClient_ALIPAY_QR() {
+ // 创建配置
+ AlipayPayClientConfig config = new AlipayPayClientConfig();
+ config.setAppId("2021000118634035");
+ config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX);
+ config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT);
+ config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN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iTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8=");
+ config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB");
+ // 创建客户端
+ Long channelId = RandomUtil.randomLong();
+ payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config);
+ PayClient client = payClientFactory.getPayClient(channelId);
+ // 发起支付
+ PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO();
+ CommonResult> result = client.unifiedOrder(reqDTO);
+ System.out.println(JsonUtils.toJsonString(result));
+ }
+
+ /**
+ * {@link AlipayWapPayClient}
+ */
+ @Test
+ public void testCreatePayClient_ALIPAY_WAP() {
+ // 创建配置
+ AlipayPayClientConfig config = new AlipayPayClientConfig();
+ config.setAppId("2021000118634035");
+ config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX);
+ config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT);
+ config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeY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DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB");
+ // 创建客户端
+ Long channelId = RandomUtil.randomLong();
+ payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config);
+ PayClient client = payClientFactory.getPayClient(channelId);
+ // 发起支付
+ PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO();
+ CommonResult> result = client.unifiedOrder(reqDTO);
+ System.out.println(JsonUtils.toJsonString(result));
+ }
+
+ private static PayOrderUnifiedReqDTO buildPayOrderUnifiedReqDTO() {
+ PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO();
+ reqDTO.setAmount(123);
+ reqDTO.setSubject("IPhone 13");
+ reqDTO.setBody("biubiubiu");
+ reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis()));
+ reqDTO.setClientIp("127.0.0.1");
+ reqDTO.setNotifyUrl("http://127.0.0.1:8080");
+ return reqDTO;
+ }
+
+}