diff --git a/internal/service/cart/cart.go b/internal/service/cart/cart.go index 7d79e12..4f77683 100644 --- a/internal/service/cart/cart.go +++ b/internal/service/cart/cart.go @@ -149,12 +149,16 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str return nil, err } + receiver.logger.Info("account for pay", zap.Any("acc", account)) + tariffs, err := receiver.hubadminClient.GetTariffs(ctx, accessToken, account.Cart) if err != nil { receiver.logger.Error("failed to get tarrifs on of ", zap.Strings("cart", account.Cart), zap.Error(err)) return nil, err } + receiver.logger.Info("tariffs for pay", zap.Any("acc", tariffs)) + tariffsAmount := utils.CalculateCartPurchasesAmount(tariffs) discountResponse, err := receiver.discountClient.Apply(ctx, &discount.ApplyDiscountRequest{ @@ -172,6 +176,8 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str return nil, err } + receiver.logger.Info("discountResponse for pay", zap.Any("acc", discountResponse)) + if account.Wallet.Money < int64(discountResponse.Price) { receiver.logger.Error("insufficient funds on of ") return nil, errors.New(fmt.Errorf("insufficient funds: %d", int64(discountResponse.Price)-account.Wallet.Money), errors.ErrInsufficientFunds)