diff --git a/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/service/config/UnionPayConfigService.java b/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/service/config/UnionPayConfigService.java index e02bef550..3a682217b 100644 --- a/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/service/config/UnionPayConfigService.java +++ b/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/service/config/UnionPayConfigService.java @@ -111,7 +111,7 @@ public class UnionPayConfigService { */ public UnionPayConfig getUnionPayConfig(){ MchAppLocal mchAppInfo = PaymentContextLocal.get().getMchAppInfo(); - ChannelConfig channelConfig = channelConfigCacheService.get(mchAppInfo.getAppId(), ChannelEnum.ALI.getCode()); + ChannelConfig channelConfig = channelConfigCacheService.get(mchAppInfo.getAppId(), ChannelEnum.UNION_PAY.getCode()); return UnionPayConfig.convertConfig(channelConfig); } @@ -134,9 +134,17 @@ public class UnionPayConfigService { } /** - * 生成云闪付支付服务 + * 生成云闪付支付接口 + */ + public UnionPayKit initPayService(){ + UnionPayConfig config = this.getUnionPayConfig(); + return this.initPayService(config); + } + /** + * 生成云闪付支付接口 */ public UnionPayKit initPayService(UnionPayConfig config){ + UnionPayConfigStorage unionPayConfigStorage = new UnionPayConfigStorage(); unionPayConfigStorage.setInputCharset(CharsetUtil.UTF_8); // 商户号 @@ -155,10 +163,12 @@ public class UnionPayConfigService { unionPayConfigStorage.setKeyPrivateCertPwd(config.getKeyPrivateCertPwd()); //设置证书对应的存储方式,证书流 unionPayConfigStorage.setCertStoreType(CertStoreType.INPUT_STREAM); - + // 签名方式 unionPayConfigStorage.setSignType(config.getSignType()); //是否为测试账号,沙箱环境 unionPayConfigStorage.setTest(config.isSandbox()); + // 回调地址 + unionPayConfigStorage.setNotifyUrl(getNotifyUrl()); // 网络请求配置 HttpConfigStorage httpConfigStorage = new HttpConfigStorage(); diff --git a/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionPayStrategy.java b/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionPayStrategy.java index e0e78a611..30df253ff 100644 --- a/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionPayStrategy.java +++ b/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionPayStrategy.java @@ -71,7 +71,7 @@ public class UnionPayStrategy extends AbsPayStrategy { */ @Override public PayResultBo doPayHandler() { - UnionPayKit unionPayKit = unionPayConfigService.initPayService(unionPayConfig); + UnionPayKit unionPayKit = unionPayConfigService.initPayService(); return unionPayService.pay(this.getOrder(), this.unionPayParam, unionPayKit); } } diff --git a/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionRefundStrategy.java b/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionRefundStrategy.java index 6df63af6f..ee98bce2a 100644 --- a/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionRefundStrategy.java +++ b/daxpay-single-channel/daxpay-single-union/src/main/java/org/dromara/daxpay/channel/union/strategy/UnionRefundStrategy.java @@ -1,7 +1,6 @@ package org.dromara.daxpay.channel.union.strategy; import lombok.RequiredArgsConstructor; -import org.dromara.daxpay.channel.union.entity.config.UnionPayConfig; import org.dromara.daxpay.channel.union.sdk.api.UnionPayKit; import org.dromara.daxpay.channel.union.service.config.UnionPayConfigService; import org.dromara.daxpay.channel.union.service.refund.UnionPayRefundService; @@ -27,8 +26,6 @@ public class UnionRefundStrategy extends AbsRefundStrategy { private final UnionPayConfigService unionPayConfigService; - private UnionPayConfig unionPayConfig; - /** * 策略标识 * @@ -39,21 +36,12 @@ public class UnionRefundStrategy extends AbsRefundStrategy { return ChannelEnum.UNION_PAY.getCode(); } - /** - * 退款前对处理, 初始化微信支付配置 - */ - @Override - public void doBeforeRefundHandler() { - this.unionPayConfig = unionPayConfigService.getAndCheckConfig(); - } - - /** * 退款操作 */ @Override public RefundResultBo doRefundHandler() { - UnionPayKit unionPayKit = unionPayConfigService.initPayService(unionPayConfig); + UnionPayKit unionPayKit = unionPayConfigService.initPayService(); return unionPayRefundService.refund(this.getRefundOrder(), unionPayKit); } } diff --git a/daxpay-single-server/src/main/resources/application-demo.yml b/daxpay-single-server/src/main/resources/application-demo.yml index 7c2b7df40..a1cbf2529 100644 --- a/daxpay-single-server/src/main/resources/application-demo.yml +++ b/daxpay-single-server/src/main/resources/application-demo.yml @@ -71,7 +71,7 @@ bootx-platform: # 使用后端代理访问, 线上请使用 Nginx 配置或者直连方式,效率更高 forward-server-url: http://127.0.0.1:9999 dax-pay: - env: DEMO_ + env: DEMO machine-no: 70 dromara: # 注意, 不要设置 domain 访问路径, 自行进行拼接访问路径, 来保证可迁移性 diff --git a/daxpay-single-server/src/main/resources/application-dev.yml b/daxpay-single-server/src/main/resources/application-dev.yml index 3f96f91ef..ef7eec001 100644 --- a/daxpay-single-server/src/main/resources/application-dev.yml +++ b/daxpay-single-server/src/main/resources/application-dev.yml @@ -75,7 +75,7 @@ bootx-platform: # 使用后端代理访问, 线上请使用 Nginx 配置或者直连方式,效率更高 forward-server-url: http://127.0.0.1:9999 dax-pay: - env: DEV_ + env: DEV machine-no: 60 dromara: # 注意, 不要设置 domain 访问路径, 自行进行拼接访问路径, 来保证可迁移性 diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/common/properties/DaxPayProperties.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/common/properties/DaxPayProperties.java index 1ec6e70f2..d5e419a9d 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/common/properties/DaxPayProperties.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/common/properties/DaxPayProperties.java @@ -22,7 +22,7 @@ public class DaxPayProperties { /** 通常为两位内 机器码, 用于区分不同机器生成的流水号 */ private String machineNo = "58"; - /** 当前环境,会影响订单号的生成 */ + /** 当前环境,会影响订单号的生成, 推荐只使用字母和数字, 部分通道不支持特殊符号, 如云闪付 */ private String env = ""; public void setMachineNo(String machineNo) {