-
Notifications
You must be signed in to change notification settings - Fork 13
/
stripe.go
34 lines (27 loc) · 907 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
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 ServiceProviderStripe() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.StripeService,
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
},
}
}