feat(currency): add currency configuration support and integrate into payment processing
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/perfect-panel/server/internal/config"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
"github.com/perfect-panel/server/pkg/logger"
|
||||
"github.com/perfect-panel/server/pkg/tool"
|
||||
)
|
||||
|
||||
func Currency(ctx *svc.ServiceContext) {
|
||||
// Retrieve system currency configuration
|
||||
currency, err := ctx.SystemModel.GetCurrencyConfig(context.Background())
|
||||
if err != nil {
|
||||
logger.Errorf("[INIT] Failed to get currency configuration: %v", err.Error())
|
||||
panic(fmt.Sprintf("[INIT] Failed to get currency configuration: %v", err.Error()))
|
||||
}
|
||||
// Parse currency configuration
|
||||
configs := struct {
|
||||
CurrencyUnit string
|
||||
CurrencySymbol string
|
||||
AccessKey string
|
||||
}{}
|
||||
tool.SystemConfigSliceReflectToStruct(currency, &configs)
|
||||
|
||||
ctx.Config.Currency = config.Currency{
|
||||
Unit: configs.CurrencyUnit,
|
||||
Symbol: configs.CurrencySymbol,
|
||||
AccessKey: configs.AccessKey,
|
||||
}
|
||||
logger.Infof("[INIT] Currency configuration: %v", ctx.Config.Currency)
|
||||
}
|
||||
@@ -15,6 +15,7 @@ func StartInitSystemConfig(svc *svc.ServiceContext) {
|
||||
Subscribe(svc)
|
||||
Register(svc)
|
||||
Mobile(svc)
|
||||
Currency(svc)
|
||||
if !svc.Config.Debug {
|
||||
Telegram(svc)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user