package com.cyl.wechat;

import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import java.io.IOException;

public class WechatPayConfig {

    private static Config wechatPayConfig;

    private WechatPayConfig(){}

    public static Config getInstance() {


        if (wechatPayConfig == null) {
            wechatPayConfig = new RSAAutoCertificateConfig.Builder()
                    .merchantId(WechatPayData.merchantId)
                    .privateKey("-----BEGIN PRIVATE KEY-----\n" +
                            "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDfPg4xpRa2Yz4q\n" +
                            "bKDPfC1FlrD+7unTL3qyoDajRBf+RR+RoOwZZuXIKkD07UJEURFug1Fk7kFECgKc\n" +
                            "oXB7QL/FyPDOj2VhM7qhZh0F9OTT2Cdfq2Dn4frfKl8q+FhKNvDhw0q6+X24Dkoz\n" +
                            "gyK4/I8KQgYGJF5MSypSwfiNdZE3ton+boVUgBBkMpnnvjTu6ToVoyljFozUrXHE\n" +
                            "5LGV7OuNHZ33lWiQqL9JAKSQPKlfRMdA4oH+I/v+O4xWRcchwPufS00aKLL/0FTc\n" +
                            "IX1lk4TkCWkONpRmhdEx2vgC4pOhi+ojN5FsRxXEdTX3BPHRYHvDwm+O11BiekLE\n" +
                            "9O/qTxOxAgMBAAECggEATk/ojsXI9+ZMknlU2DRJdVXtdSC+adUIB81oHVHv0MTS\n" +
                            "1DVNXYPZK6SW8NSiIHEH2mq6jNt/jaytSeDgInyOSYW549wtxjFtUN0PZV2JQD9d\n" +
                            "YJQwBGgjp1Gn3N0Nq8smKSxm9Lw8u+pXYUapUZdXXlPW5SSw57aefDWLSaRqcs4w\n" +
                            "TmruBaTTXGXyqjijQ2CRmxMaxH8kksetretHUyvgUGPntMXcROoIN22DbCkKiOdh\n" +
                            "F5IEDKdfCB/P+4nI0pmbaCm8mbRb7jykptJg3/sHu0cKLD4JNHNwOzk2hUmIIPk0\n" +
                            "tw+VNgJBP4xnhOZlEe+mdGBGqQD1ZqXHCWYg0bkoIQKBgQDzM8aq3xvDiDXBX7+O\n" +
                            "rVEOTA05w/B4AvPxXSOqxCGlPjBPoxHGcDCwNYoNQvZU2NYKbOWOhZZm0vUw1uqm\n" +
                            "beXrfnWlYXycUl3aKI6k8YHrMTMvwgtLJXVIguvCW2Pup1gWX+uAuybaJl5ynnpf\n" +
                            "vjawxUxwDZYjh76V8jJOdzEtVQKBgQDq/WWBJbLFPYSjyuzthZaZ5aOAI8VZMNEr\n" +
                            "iWTm2zN7+jUVOIwVorQtQjZPCZyTh3U9m60BBrZixsIogVGAuplR/B63YkB1hWut\n" +
                            "SKnauJLzcgsOQa1lmWHnJcxtA2eZ1iGuH2eiFB/c0GEznpVId40Gs3fEpt+xR45h\n" +
                            "W4h1Iges7QKBgAkcPGn0N58IgDMBOjTHC01Ezg4G6AAm5Cp7ebWQ6U2+WaLyEd1k\n" +
                            "IH7JUqWSh5XAFayITcUb/flWF7c/pcScQ0uiDhgm4bsdXsSoVkeZgGtmCWvVkgS7\n" +
                            "n3wa42gBcmnjPOqBp1nIKPltDIawpxblEjlm+qkL6T7le980FmxYDLCNAoGBAJv8\n" +
                            "+ZRxYepsm8/etMg3FXGzboVxOV+reC5eVgypFdQGk5Yyo0r5ZoFkooh06OtF0B3F\n" +
                            "aWJ1Aj0vk1MwBNpfA8fYhMtW/VMF7iRpR9dZDrNr0Mr17hSzbLnz7W+wAuWrr0/W\n" +
                            "qQR+N2htKxkI/C/OrF72Y1q3K2aTCYC3Mi4PGOlBAoGBAJGIuDGQVaWY7XlKNYqk\n" +
                            "g+0l3CoPO1GokGU17YVzrM4UrvNqPy6R/+KHtX/XYd0kh+4xHKEIydC2TZXHvdvo\n" +
                            "AuP1zrEmnV0FZy8quw+89KX5uj0SO81yGHReDawlG2AAMZc6SmYrEFumlFKBOeVn\n" +
                            "Hf8trwRlMLiv+10a4bwZtNon\n" +
                            "-----END PRIVATE KEY-----\n")
                    .merchantSerialNumber(WechatPayData.merchantSerialNumber)
                    .apiV3Key(WechatPayData.apiV3key)
                    .build();
        }
        return wechatPayConfig;
    }
}
