Add Balance and Withdrawal

This commit is contained in:
aditya.siregar
2024-07-31 23:02:15 +07:00
parent 38003f84d1
commit 4c1a819365
19 changed files with 434 additions and 69 deletions
+5
View File
@@ -31,6 +31,7 @@ type Config struct {
Midtrans Midtrans `mapstructure:"midtrans"`
Brevo Brevo `mapstructure:"brevo"`
Email Email `mapstructure:"email"`
Withdraw Withdraw `mapstructure:"withdrawal"`
}
var (
@@ -73,5 +74,9 @@ func (c *Config) Auth() *AuthConfig {
secret: c.Jwt.TokenResetPassword.Secret,
expireTTL: c.Jwt.TokenResetPassword.ExpiresTTL,
},
jwtWithdraw: JWT{
secret: c.Jwt.TokenWithdraw.Secret,
expireTTL: c.Jwt.TokenWithdraw.ExpiresTTL,
},
}
}
+10
View File
@@ -8,6 +8,7 @@ type AuthConfig struct {
jwtOrderSecret string
jwtOrderExpiresTTL int
jwtSecretResetPassword JWT
jwtWithdraw JWT
}
type JWT struct {
@@ -23,6 +24,15 @@ func (c *AuthConfig) AccessTokenOrderSecret() string {
return c.jwtOrderSecret
}
func (c *AuthConfig) AccessTokenWithdrawSecret() string {
return c.jwtWithdraw.secret
}
func (c *AuthConfig) AccessTokenWithdrawExpire() time.Time {
duration := time.Duration(c.jwtWithdraw.expireTTL)
return time.Now().UTC().Add(time.Minute * duration)
}
func (c *AuthConfig) AccessTokenOrderExpiresDate() time.Time {
duration := time.Duration(c.jwtOrderExpiresTTL)
return time.Now().UTC().Add(time.Minute * duration)
+1
View File
@@ -4,6 +4,7 @@ type Jwt struct {
Token Token `mapstructure:"token"`
TokenOrder Token `mapstructure:"token-order"`
TokenResetPassword Token `mapstructure:"token-reset-password"`
TokenWithdraw Token `mapstructure:"token-withdraw"`
}
type Token struct {
+9
View File
@@ -0,0 +1,9 @@
package config
type Withdraw struct {
PlatformFee int64 `mapstructure:"platform_fee"`
}
func (w *Withdraw) GetPlatformFee() int64 {
return w.PlatformFee
}