-
Notifications
You must be signed in to change notification settings - Fork 14
/
stripe.go
35 lines (28 loc) · 915 Bytes
/
stripe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package registry
import (
"errors"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/app"
"github.com/coretrix/hitrix/service/component/config"
stripe2 "github.com/coretrix/hitrix/service/component/stripe"
"github.com/sarulabs/di"
)
func ServiceDefinitionStripe() *service.Definition {
return &service.Definition{
Name: service.StripeService,
Global: true,
Build: func(ctn di.Container) (interface{}, error) {
configService := ctn.Get(service.ConfigService).(config.IConfig)
key, ok := configService.String("stripe.key")
if ok {
return nil, errors.New("missing stripe key")
}
secrets, ok := configService.StringMap("stripe.webhook_secrets")
if !ok {
return nil, errors.New("missing stripe secrets")
}
appService := ctn.Get(service.AppService).(*app.App)
return stripe2.NewStripe(key, secrets, appService.Mode), nil
},
}
}