-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from rocboss/jc/alimy
optimize alipay initial client logic
- Loading branch information
Showing
10 changed files
with
53 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
data | ||
.vscode | ||
release | ||
custom | ||
*Dockerfile* | ||
web/node_modules | ||
web/src-tauri/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
config.yaml | ||
*.log | ||
paopao-ce* | ||
release | ||
data | ||
/release | ||
/data | ||
/custom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,46 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/rocboss/paopao-ce/internal/conf" | ||
"github.com/rocboss/paopao-ce/internal/core" | ||
"github.com/rocboss/paopao-ce/internal/dao" | ||
"github.com/sirupsen/logrus" | ||
"github.com/smartwalle/alipay/v3" | ||
) | ||
|
||
var ( | ||
alipayClient *alipay.Client | ||
objectStorage core.ObjectStorageService | ||
) | ||
|
||
func Initialize() { | ||
objectStorage = dao.ObjectStorageService() | ||
|
||
if conf.CfgIf("Alipay") { | ||
initAlipay() | ||
} | ||
} | ||
|
||
func initAlipay() { | ||
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters