Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qbhy/goal-alipay
支付宝sdk for goal
https://github.com/qbhy/goal-alipay
Last synced: 20 days ago
JSON representation
支付宝sdk for goal
- Host: GitHub
- URL: https://github.com/qbhy/goal-alipay
- Owner: qbhy
- Created: 2022-02-27T05:19:39.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-23T07:03:42.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T13:33:51.008Z (6 months ago)
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# goal-aliyun
这是一个 goal 的支付宝 sdk,基于 [smartwalle/alipay](https://github.com/smartwalle/alipay) 封装,支持多应用## 安装 - install
```shell
$ go get github.com/qbhy/goal-alipay
```## 配置 - configuration
```go
// config/alipay.go
package configimport (
"github.com/goal-web/contracts"
alipay "github.com/qbhy/goal-alipay"
)func init() {
configs["alipay"] = func(env contracts.Env) interface{} {
return &alipay.Config{
Default: env.StringOption("alipay.default", "default"),
Apps: map[string]*alipay.AppConfig{
"default": {
AppId: env.GetString("alipay.appid"),
PrivateKey: env.GetString("alipay.private_key"),
IsProduction: !env.GetBool("alipay.debug"),
//OptionFunctions: []alipay.OptionFunc{
// func(c *alipay2.Client) {
// // do something
// },
//},
},
},
}
}
}```
## 使用 - usage
注册服务
```go
// main.go
import (
"github.com/goal-web/application"
alipay "github.com/qbhy/goal-alipay"
)func main() {
var app = application.Singleton()
app.RegisterServices(
// other service
alipay.ServiceProvider{},
)
// ...
}
```
使用
```go
// app/controllers/order/pay.goimport (
"fmt"
"github.com/goal-web/contracts"
alipay "github.com/qbhy/goal-alipay"
alipayWalle "github.com/smartwalle/alipay/v3"
)// ...
// 通过注入支付宝工厂,你可以通过工厂获取定义好的应用
func AppTrade(alipay alipay.Factory, request contracts.HttpRequest) {
var client = alipay.Client("default")
}// 你也可以直接注入 支付宝kehuduan 的实例,这种情况下会获取默认实例
func InjectInstanceExample(client *alipayWalle.Client) {
// do something ...
}// ...
```## 相关链接
[goal-web](https://github.com/goal-web/goal)
[qbhy/goal-alipay](https://github.com/qbhy/goal-alipay)
[smartwalle/alipay](https://github.com/smartwalle/alipay)
[email protected]