package com.xunwang.payment.config;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Guan
 * @date 2023/4/6
 * discription
 */
@Configuration
public class WxMpConfig {
    @Bean
    public WxMpDefaultConfigImpl wxMpDefaultConfigImpl() {
        WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
        config.setAppId("wx89420f00e823c9ec"); // 设置微信公众号的appid
        config.setSecret("17eb4a2499cf02d807df515ff0949998"); // 设置微信公众号的app corpSecret
        config.setToken("1e3b5fbd4d4e4978923cd647d4509d2b"); // 设置微信公众号的token
        config.setAesKey("OvUMHmtBSyi4Ol5S5RDit07UsME3FfTdoomaKl7srPw"); // 设置微信公众号的EncodingAESKey
        return config;
    }

    @Bean
    public WxMpService wxMpService() {
        WxMpService wxMpService = new WxMpServiceImpl();// 实际项目中请注意要保持单例，不要在每次请求时构造实例，具体可以参考demo项目
        wxMpService.setWxMpConfigStorage(wxMpDefaultConfigImpl());
        return wxMpService;
    }
}
