package com.keao.edu.thirdparty.adapay;

import com.huifu.adapay.Adapay;
import com.huifu.adapay.model.MerConfig;


public class ConfigInit {


    private static ConfigInit instance;
    public final static Integer organId = 46; //商户对应的分部
    public final static String merNo = "B09767221"; //商户对应的分部
    public final static String appId = "app_f0ebdd29-046f-4b60-bd50-92e2c1285c02";

    public final static String wxAppId = "wx751141096e75a4ee";
    public final static String wxAppSecret = "e882d76c95d1613607a85338b1bed3ff";
    public final static String wxMpOAuth2AccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
    public final static MerConfig merConfig = new MerConfig();

    static {
        try {
            instance = initConfig();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    private static ConfigInit initConfig() throws Exception {
        if (instance == null) {
            instance = new ConfigInit();
        } else {
            return instance;
        }

        Adapay.debug = true;

        /**
         * prodMode 模式，默认为生产模式，false可以使用mock模式
         */
        Adapay.prodMode = true;

        /**
         *添加商户配置，一个商户只需要 添加一次，添加以后在内存中。
         */

        String apiKey = "api_live_8dd6fba0-59ca-45f7-8e82-0b3ae7bd7907";
        String mockApiKey = "api_test_193c8f6a-514f-4d95-a26b-2861c7971105";
        String rsaPrivateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAL3zHDr2s5Lp3b9FKAD4vB3Y2MyOypv68mKFi8uPznO9JkzBhwYLYRC8mnP+W7tw5Q7Yuf5Szhn8Mo9KZ8Bsv6S6iz3BtXzeHb/8nyeBAH2m477bJzwmapZPhPSroR8md1dnNI+4NttM/0Cn/rdAySzQn+IPHLPxWFwQw+y6FFi7AgMBAAECgYEAkuUBPfAvKzxEyng22ZmCESrzbi43La1B6UMRuxi5NfRfPBilzNzb8c+JOo7Ibgp+eZ7NJ4rt7FaG2x1VYxA2m151I86e6TlgPYNjjj56RpkrD9/LrDqePFE4AlrwO5802fK4X/iac1MCpEhaiVNQ3x6ikwcKWzKmMV/EpdijIcECQQDlt+ou3L5M2TQW8YYg9zA9TKRd+M/Xs0tPLJLE+W6m0+dmyeHBErMW6X874qhmIc3F8HYIW+O51GMy6KDgQ7PrAkEA065ujs1ZkwIPMopgIoqlRi8JDvAxgEZqktDDMMg0o2XZP6J7C5suf2BsrhKnjLlxII7dQPxDfPDiRz4jYpBKcQJBAKd77ev42W5iNk48DdTfJHas+HHjRHY5rMCu+NtQGNLdUKtqqYQBRD2CRFe/K5Q7NTIJ3aS+ikwkg6bMYO7hrb0CQDesuC1c+0M8Fm0vketj1eZotpQ0PoDDhIJK4BuzfIzBW+ttu7kovokH/m2mQGU13Pg4Ox89ei6hWJJuWHYzBzECQQDexzziaTpHMy3achL2M2pOSdaSLYoesmPTmVZ3kOZf82FpRlfxVGUs0nKpEEgagUkiHUQHAu5RVkxIiDqMYrQp";

        merConfig.setApiKey(apiKey);
        merConfig.setApiMockKey(mockApiKey);
        merConfig.setRSAPrivateKey(rsaPrivateKey);
        Adapay.initWithMerConfig(merConfig);
        /**
         *启动MQTT，一个商户只需要 启动一次，启动完成以后一直在服务器后端运行
         */
        // notifyCallback = new NotifyCallback();
        //Adapay.startMqttListener(merConfig, notifyCallback);
        return instance;
    }

    public ConfigInit() {
    }
}
