add order and payment

This commit is contained in:
aditya.siregar
2024-06-04 02:59:31 +07:00
parent 8a23e72230
commit 4ae9079ff9
34 changed files with 810 additions and 1172 deletions
+3
View File
@@ -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,
}
}
+11
View File
@@ -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
View File
@@ -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 {
+25
View File
@@ -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
}