Files
jsowell-charger-web/jsowell-pile/src/main/java/com/jsowell/wxpay/config/WechatPayConfig.java
2024-06-11 15:12:02 +08:00

99 lines
2.4 KiB
Java

package com.jsowell.wxpay.config;
import com.jsowell.wxpay.common.WeChatPayParameter;
import com.jsowell.wxpay.utils.WechatPayUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Order(3)
@Component
public class WechatPayConfig implements CommandLineRunner {
/**
* 公众号appid
*/
@Value("${wechat.appId}")
private String wechatAppId;
/**
* 商户号id
*/
@Value("${wechat.mchId}")
private String wechatMchId;
/**
* 商户序列号
*/
@Value("${wechat.mchSerialNo}")
private String mchSerialNo;
/**
* 支付key
*/
@Value("${wechat.v3Key}")
private String wechatV3Key;
/**
* 微信支付回调url
*/
@Value("${wechat.callback}")
private String payCallbackUrl;
/**
* 微信退款回调url
*/
@Value("${wechat.refundCallback}")
private String refundCallbackUrl;
/**
* 统一下单url
*/
@Value("${wechat.unifiedOrder.url}")
private String wechatUnifiedOrderUrl;
/**
* 统一下单url
*/
@Value("${wechat.unifiedOrder.jsurl}")
private String wechatUnifiedOrderUrlJS;
/**
* jsapi申请退款url
*/
@Value("${wechat.refund.jsurl}")
private String wechatRefundJsUrl;
/**
* 平台证书列表地址
*/
@Value("${wechat.certificates.url}")
private String wechatCertificatesUrl;
/**
* 商户私钥路径
*/
@Value("${wechat.key.path}")
private String wechatKeyPath;
@Override
public void run(String... args) throws Exception {
System.out.println(">>>>>>>>>>>>>>>服务启动执行,执行加载数据等操作 WechatPayConfig order 3 <<<<<<<<<<<<<");
//微信支付
WeChatPayParameter.mchId = wechatMchId;
WeChatPayParameter.appId = wechatAppId;
WeChatPayParameter.v3Key = wechatV3Key;
WeChatPayParameter.certificatesUrl = wechatCertificatesUrl;
WeChatPayParameter.unifiedOrderUrl = wechatUnifiedOrderUrl;
WeChatPayParameter.unifiedOrderUrlJS = wechatUnifiedOrderUrlJS;
WeChatPayParameter.notifyUrl = payCallbackUrl;
WeChatPayParameter.refundJsUrl = wechatRefundJsUrl;
WeChatPayParameter.refundNotifyUrl = refundCallbackUrl;
//加载商户私钥
WeChatPayParameter.privateKey = WechatPayUtils.getPrivateKey(wechatKeyPath);
WeChatPayParameter.mchSerialNo = mchSerialNo;
//获取平台证书
WeChatPayParameter.certificateMap = WechatPayUtils.refreshCertificate();
}
}