|
|
|
@ -22,30 +22,28 @@ func Initialize() {
|
|
|
|
|
objectStorage = dao.ObjectStorageService()
|
|
|
|
|
|
|
|
|
|
if cfg.If("Alipay") {
|
|
|
|
|
initAlipay()
|
|
|
|
|
alipayClient = mustAlipayClient()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func initAlipay() {
|
|
|
|
|
func mustAlipayClient() *alipay.Client {
|
|
|
|
|
s := conf.AlipaySetting
|
|
|
|
|
// 将 key 的验证调整到初始化阶段
|
|
|
|
|
client, err := alipay.New(s.AppID, s.PrivateKey, s.InProduction)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Fatalf("alipay.New err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 加载应用公钥证书
|
|
|
|
|
if err = client.LoadAppPublicCertFromFile(s.AppPublicCertFile); err != nil {
|
|
|
|
|
logrus.Fatalf("client.LoadAppPublicCertFromFile err: %s\n", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 加载支付宝根证书
|
|
|
|
|
if err = client.LoadAliPayRootCertFromFile(s.RootCertFile); err != nil {
|
|
|
|
|
logrus.Fatalf("client.LoadAliPayRootCertFromFile err: %s\n", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 加载支付宝公钥证书
|
|
|
|
|
if err = client.LoadAliPayPublicCertFromFile(s.PublicCertFile); err != nil {
|
|
|
|
|
logrus.Fatalf("client.LoadAliPayPublicCertFromFile err: %s\n", err)
|
|
|
|
|
}
|
|
|
|
|
return client
|
|
|
|
|
}
|
|
|
|
|