//package com.ruoyi.api.util;
//
//import com.github.binarywang.wxpay.config.WxPayConfig;
//import com.github.binarywang.wxpay.service.WxPayService;
//import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
//import com.ruoyi.common.utils.StringUtils;
//import com.ruoyi.payConfig.WechatPayConfig;
//import lombok.AllArgsConstructor;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//@AllArgsConstructor
//@ConditionalOnClass(WxPayService.class)
//public class ShopBeanConfig {
//    @Autowired
//    private  WechatPayConfig wechatPayConfig;
//
//
//
//    @Bean
//    public WxPayService wxService() {
//        WxPayConfig payConfig = new WxPayConfig();
//        payConfig.setAppId(StringUtils.trimToNull(wechatPayConfig.getAppId()));
//        payConfig.setMchId(StringUtils.trimToNull(wechatPayConfig.getMchId()));
//        payConfig.setMchKey(StringUtils.trimToNull(wechatPayConfig.getMchKey()));
//        payConfig.setKeyPath(StringUtils.trimToNull(wechatPayConfig.getKeyPath()));
//        payConfig.setApiV3Key(StringUtils.trimToNull(wechatPayConfig.getApiV3Key()));
//        payConfig.setCertSerialNo(StringUtils.trimToNull(wechatPayConfig.getSerialNo()));
//        payConfig.setPrivateKeyPath(StringUtils.trimToNull(wechatPayConfig.getPrivateKeyPath()));
//        payConfig.setPrivateCertPath(StringUtils.trimToNull(wechatPayConfig.getPrivateCertPath()));
//        payConfig.setNotifyUrl(StringUtils.trimToNull(wechatPayConfig.getZhuanNotifyUrl()));
//
//        // 可以指定是否使用沙箱环境
//        payConfig.setUseSandboxEnv(false);
//
//        WxPayService wxPayService = new WxPayServiceImpl();
//        wxPayService.setConfig(payConfig);
//        return wxPayService;
//    }
//}
