This commit is contained in:
Yared Yemane 2025-06-18 11:17:32 +03:00
parent 2bd8181494
commit 9f5004206c

View File

@ -148,10 +148,10 @@ func (s *service) HandleCallback(ctx context.Context, callback *domain.PopOKCall
func (s *service) GetPlayerInfo(ctx context.Context, req *domain.PopOKPlayerInfoRequest) (*domain.PopOKPlayerInfoResponse, error) {
claims, err := jwtutil.ParsePopOKJwt(req.ExternalToken, s.config.PopOK.SecretKey)
if err != nil {
s.logger.Error("Failed to parse JWT", "error", err)
return nil, fmt.Errorf("invalid token")
}
// if err != nil {
// s.logger.Error("Failed to parse JWT", "error", err)
// return nil, fmt.Errorf("invalid token")
// }
wallets, err := s.walletSvc.GetWalletsByUser(ctx, claims.UserID)
if err != nil || len(wallets) == 0 {
@ -170,9 +170,9 @@ func (s *service) GetPlayerInfo(ctx context.Context, req *domain.PopOKPlayerInfo
func (s *service) ProcessBet(ctx context.Context, req *domain.PopOKBetRequest) (*domain.PopOKBetResponse, error) {
// Validate token and get user ID
claims, err := jwtutil.ParsePopOKJwt(req.ExternalToken, s.config.PopOK.SecretKey)
if err != nil {
return nil, fmt.Errorf("invalid token")
}
// if err != nil {
// return nil, fmt.Errorf("invalid token")
// }
// Convert amount to cents (assuming wallet uses cents)
amountCents := int64(req.Amount * 100)
@ -214,10 +214,10 @@ func (s *service) ProcessBet(ctx context.Context, req *domain.PopOKBetRequest) (
func (s *service) ProcessWin(ctx context.Context, req *domain.PopOKWinRequest) (*domain.PopOKWinResponse, error) {
// 1. Validate token and get user ID
claims, err := jwtutil.ParsePopOKJwt(req.ExternalToken, s.config.PopOK.SecretKey)
if err != nil {
s.logger.Error("Invalid token in win request", "error", err)
return nil, fmt.Errorf("invalid token")
}
// if err != nil {
// s.logger.Error("Invalid token in win request", "error", err)
// return nil, fmt.Errorf("invalid token")
// }
// 2. Check for duplicate transaction (idempotency)
existingTx, err := s.repo.GetVirtualGameTransactionByExternalID(ctx, req.TransactionID)
@ -280,10 +280,10 @@ func (s *service) ProcessWin(ctx context.Context, req *domain.PopOKWinRequest) (
func (s *service) ProcessCancel(ctx context.Context, req *domain.PopOKCancelRequest) (*domain.PopOKCancelResponse, error) {
// 1. Validate token and get user ID
claims, err := jwtutil.ParsePopOKJwt(req.ExternalToken, s.config.PopOK.SecretKey)
if err != nil {
s.logger.Error("Invalid token in cancel request", "error", err)
return nil, fmt.Errorf("invalid token")
}
// if err != nil {
// s.logger.Error("Invalid token in cancel request", "error", err)
// return nil, fmt.Errorf("invalid token")
// }
// 2. Find the original bet transaction
originalBet, err := s.repo.GetVirtualGameTransactionByExternalID(ctx, req.TransactionID)