add order and payment
This commit is contained in:
@@ -28,6 +28,7 @@ type Config struct {
|
||||
Database Database `mapstructure:"postgresql"`
|
||||
Jwt Jwt `mapstructure:"jwt"`
|
||||
OSSConfig OSSConfig `mapstructure:"oss"`
|
||||
Midtrans Midtrans `mapstructure:"midtrans"`
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -64,5 +65,7 @@ func (c *Config) Auth() *AuthConfig {
|
||||
return &AuthConfig{
|
||||
jwtTokenSecret: c.Jwt.Token.Secret,
|
||||
jwtTokenExpiresTTL: c.Jwt.Token.ExpiresTTL,
|
||||
jwtOrderSecret: c.Jwt.TokenOrder.Secret,
|
||||
jwtOrderExpiresTTL: c.Jwt.TokenOrder.ExpiresTTL,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,23 @@ import "time"
|
||||
type AuthConfig struct {
|
||||
jwtTokenExpiresTTL int
|
||||
jwtTokenSecret string
|
||||
jwtOrderSecret string
|
||||
jwtOrderExpiresTTL int
|
||||
}
|
||||
|
||||
func (c *AuthConfig) AccessTokenSecret() string {
|
||||
return c.jwtTokenSecret
|
||||
}
|
||||
|
||||
func (c *AuthConfig) AccessTokenOrderSecret() string {
|
||||
return c.jwtOrderSecret
|
||||
}
|
||||
|
||||
func (c *AuthConfig) AccessTokenOrderExpiresDate() time.Time {
|
||||
duration := time.Duration(c.jwtOrderExpiresTTL)
|
||||
return time.Now().UTC().Add(time.Minute * duration)
|
||||
}
|
||||
|
||||
func (c *AuthConfig) AccessTokenExpiresDate() time.Time {
|
||||
duration := time.Duration(c.jwtTokenExpiresTTL)
|
||||
return time.Now().UTC().Add(time.Minute * duration)
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package config
|
||||
|
||||
type Jwt struct {
|
||||
Token Token `mapstructure:"token"`
|
||||
Token Token `mapstructure:"token"`
|
||||
TokenOrder Token `mapstructure:"token-order"`
|
||||
}
|
||||
|
||||
type Token struct {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package config
|
||||
|
||||
type Midtrans struct {
|
||||
Serverkey string `mapstructure:"server_key"`
|
||||
Clientkey string `mapstructure:"client_key"`
|
||||
Env int `mapstructure:"env"`
|
||||
}
|
||||
|
||||
type MidtransConfig interface {
|
||||
MidtransServerKey() string
|
||||
MidtransClientKey() string
|
||||
MidtranEnvType() int
|
||||
}
|
||||
|
||||
func (c *Midtrans) MidtransServerKey() string {
|
||||
return c.Serverkey
|
||||
}
|
||||
|
||||
func (c *Midtrans) MidtransClientKey() string {
|
||||
return c.Clientkey
|
||||
}
|
||||
|
||||
func (c *Midtrans) MidtranEnvType() int {
|
||||
return c.Env
|
||||
}
|
||||
Reference in New Issue
Block a user