Files
qingcheng-houduan/src/main/java/com/greenorange/promotion/config/WxPayConfig.java
2025-08-14 10:51:23 +08:00

79 lines
2.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//package com.greenorange.promotion.config;
//
//import com.wechat.pay.java.core.RSAAutoCertificateConfig;
//import com.wechat.pay.java.core.util.IOUtil;
//import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
//import com.wechat.pay.java.service.refund.RefundService;
//import lombok.Data;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//
//@Data
//@Slf4j
//@Configuration
//@Component("WxPayConfig")
//@ConfigurationProperties(prefix = "wx.pay")
//public class WxPayConfig {
//
// private String appId;
//
// private String apiV3Key;
//
// private String notifyUrl;
//
// private String merchantId;
//
// private String privateKeyPath;
//
// private String merchantSerialNumber;
//
// // RSA配置
// private RSAAutoCertificateConfig RSAConfig;
//
// // JSAPI支付
// private JsapiServiceExtension jsapiServiceExtension;
//
// // 退款
// private RefundService refundService;
//
// /**
// * 初始化配置
// */
// @Bean
// public boolean initWxPayConfig() throws IOException {
// this.RSAConfig = buildRSAAutoCertificateConfig();
// this.jsapiServiceExtension = buildJsapiServiceExtension(RSAConfig);
// this.refundService = buildRefundService(RSAConfig);
// return true;
// }
//
// // 构建并使用自动更新平台证书的RSA配置一个商户号只能初始化一个配置否则会因为重复的下载任务报错
// private RSAAutoCertificateConfig buildRSAAutoCertificateConfig() throws IOException {
// // 将 resource 目录下的文件转为 InputStream然后利用 IOUtil.toString(inputStream) 转化为密钥
// String privateKey = IOUtil.toString(new ClassPathResource(privateKeyPath).getInputStream());
// return new RSAAutoCertificateConfig.Builder()
// .merchantId(merchantId)
// .privateKey(privateKey)
// .merchantSerialNumber(merchantSerialNumber)
// .apiV3Key(apiV3Key)
// .build();
// }
//
// // 构建JSAPI支付
// private JsapiServiceExtension buildJsapiServiceExtension(RSAAutoCertificateConfig config) {
// return new JsapiServiceExtension.Builder().config(config).build();
// }
//
// // 构建退款
// private RefundService buildRefundService(RSAAutoCertificateConfig config) {
// return new RefundService.Builder().config(config).build();
// }
//
//}