|
@@ -163,78 +163,16 @@ public class PaymentConfig {
|
|
|
|
|
|
|
|
// ======================== 安心付支付宝客户端(小程序应用) ========================
|
|
// ======================== 安心付支付宝客户端(小程序应用) ========================
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 安心付支付宝客户端(小程序应用 - 周期卡会员管理)
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * 安心付支付宝客户端已暂停。
|
|
|
*
|
|
*
|
|
|
- * <p>安心付对应的是支付宝小程序应用,与网页应用(二维码付款)使用不同的
|
|
|
|
|
- * appId、密钥和证书,因此需要独立的 AlipayClient,不能共用 {@link #alipayClient()}。
|
|
|
|
|
|
|
+ * 原因:同一个 Spring 容器不允许同时存在两个 AlipayClient Bean,
|
|
|
|
|
+ * 使用 @Qualifier 或 @ConditionalOnProperty 在本项目实际运行中仍会导致
|
|
|
|
|
+ * NoUniqueBeanDefinitionException。安心付功能先停止,后续如恢复需重新设计
|
|
|
|
|
+ * (例如独立服务、非 Spring 容器管理客户端、或彻底拆分上下文)。
|
|
|
*
|
|
*
|
|
|
- * <p>仅当 payment.anxin-alipay.enabled=true 且 payment.mock=false 时注册。
|
|
|
|
|
- * 当前安心付功能先停止,默认不启用。
|
|
|
|
|
- * 支持公钥模式(优先)和证书模式(备选),与 {@link #alipayClient()} 逻辑一致。
|
|
|
|
|
|
|
+ * 原实现保留在 Git 历史中,如需恢复可参考历史提交。
|
|
|
*/
|
|
*/
|
|
|
- @Bean("anxinAlipayClient")
|
|
|
|
|
- @ConditionalOnProperty(prefix = "payment.anxin-alipay", name = "enabled", havingValue = "true")
|
|
|
|
|
- @ConditionalOnProperty(prefix = "payment", name = "mock", havingValue = "false")
|
|
|
|
|
- public AlipayClient anxinAlipayClient() throws Exception {
|
|
|
|
|
- PaymentProperties.AnxinAlipay ax = paymentProperties.getAnxinAlipay();
|
|
|
|
|
-
|
|
|
|
|
- if (ax.getAppId() == null || ax.getAppId().isBlank()) {
|
|
|
|
|
- log.warn("未配置 payment.anxin-alipay.app-id,跳过安心付支付宝客户端初始化");
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 公钥模式(优先)
|
|
|
|
|
- if (ax.getAlipayPublicKey() != null && !ax.getAlipayPublicKey().isBlank()) {
|
|
|
|
|
- log.info("初始化安心付支付宝客户端(公钥模式): appId={}, serverUrl={}",
|
|
|
|
|
- ax.getAppId(), ax.getServerUrl());
|
|
|
|
|
-
|
|
|
|
|
- String privateKey = ax.getAppPrivateKey();
|
|
|
|
|
- if ((privateKey == null || privateKey.isBlank())
|
|
|
|
|
- && ax.getAppPrivateKeyPath() != null && !ax.getAppPrivateKeyPath().isBlank()) {
|
|
|
|
|
- privateKey = readFileContent(ax.getAppPrivateKeyPath());
|
|
|
|
|
- log.info("已从文件读取安心付应用私钥: {}", ax.getAppPrivateKeyPath());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return new DefaultAlipayClient(
|
|
|
|
|
- ax.getServerUrl(),
|
|
|
|
|
- ax.getAppId(),
|
|
|
|
|
- privateKey,
|
|
|
|
|
- ax.getFormat(),
|
|
|
|
|
- ax.getCharset(),
|
|
|
|
|
- ax.getAlipayPublicKey(),
|
|
|
|
|
- ax.getSignType()
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 证书模式(备选)
|
|
|
|
|
- if (ax.getAppCertPath() != null && !ax.getAppCertPath().isBlank()) {
|
|
|
|
|
- log.info("初始化安心付支付宝客户端(证书模式): appId={}, serverUrl={}",
|
|
|
|
|
- ax.getAppId(), ax.getServerUrl());
|
|
|
|
|
-
|
|
|
|
|
- String privateKey = ax.getAppPrivateKey();
|
|
|
|
|
- if (ax.getAppPrivateKeyPath() != null && !ax.getAppPrivateKeyPath().isBlank()) {
|
|
|
|
|
- privateKey = readFileContent(ax.getAppPrivateKeyPath());
|
|
|
|
|
- log.info("安心付应用私钥: {}", ax.getAppPrivateKeyPath());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- CertAlipayRequest certRequest = new CertAlipayRequest();
|
|
|
|
|
- certRequest.setServerUrl(ax.getServerUrl());
|
|
|
|
|
- certRequest.setAppId(ax.getAppId());
|
|
|
|
|
- certRequest.setPrivateKey(privateKey);
|
|
|
|
|
- certRequest.setFormat(ax.getFormat());
|
|
|
|
|
- certRequest.setCharset(ax.getCharset());
|
|
|
|
|
- certRequest.setSignType(ax.getSignType());
|
|
|
|
|
- certRequest.setCertPath(resolveFilePath(ax.getAppCertPath()));
|
|
|
|
|
- certRequest.setAlipayPublicCertPath(resolveFilePath(ax.getAlipayCertPath()));
|
|
|
|
|
- certRequest.setRootCertPath(resolveFilePath(ax.getAlipayRootCertPath()));
|
|
|
|
|
-
|
|
|
|
|
- return new DefaultAlipayClient(certRequest);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- log.warn("安心付配置不完整:需要配置公钥模式(alipay-public-key)或证书模式(app-cert-path),并确保已配置应用私钥(app-private-key),跳过安心付支付宝客户端初始化");
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 微信支付客户端(仅 payment.mock=false 时注册)
|
|
* 微信支付客户端(仅 payment.mock=false 时注册)
|