diff --git a/.env.example b/.env.example index 6962ce7..e4459c4 100644 --- a/.env.example +++ b/.env.example @@ -53,6 +53,8 @@ YOOKASSA_AUTOPAYMENTS_REQUIRE_CARD_BINDING=True # # Nalogo (self-employed receipts) NALOGO_INN=your_inn # INN for nalog.ru NALOGO_PASSWORD=your_nalogo_password # Password for nalog.ru +NALOGO_RECEIPT_NAME_SUBSCRIPTION=subscription {months} months # Receipt name for time-based subscriptions ({months} = duration) +NALOGO_RECEIPT_NAME_TRAFFIC=traffic package {gb} GB # Receipt name for traffic packages ({gb} = traffic amount) # FreeKassa Payment Gateway Configuration FREEKASSA_MERCHANT_ID=your_shop_id # Your shop ID in FreeKassa diff --git a/bot/handlers/user/payment.py b/bot/handlers/user/payment.py index 05fc6de..89ff564 100644 --- a/bot/handlers/user/payment.py +++ b/bot/handlers/user/payment.py @@ -282,9 +282,9 @@ async def process_successful_payment(session: AsyncSession, bot: Bot, receipt_item_name = payment_info_from_webhook.get("description") if not receipt_item_name: if sale_mode == "traffic": - receipt_item_name = f"Remnawave traffic package {traffic_label} GB" + receipt_item_name = settings.NALOGO_RECEIPT_NAME_TRAFFIC.format(gb=traffic_label) else: - receipt_item_name = f"Remnawave subscription {int(subscription_months)} months" + receipt_item_name = settings.NALOGO_RECEIPT_NAME_SUBSCRIPTION.format(months=int(subscription_months)) try: await nalogo_service.create_income_receipt( item_name=receipt_item_name, diff --git a/bot/services/nalogo_service.py b/bot/services/nalogo_service.py index 9f7c116..c9438eb 100644 --- a/bot/services/nalogo_service.py +++ b/bot/services/nalogo_service.py @@ -61,10 +61,12 @@ class NalogoService: return None try: + # API expects quantity as integer when it's a whole number + qty = int(quantity) if float(quantity).is_integer() else Decimal(str(quantity)) service_item = IncomeServiceItem( name=item_name, amount=Decimal(str(amount)), - quantity=Decimal(str(quantity)), + quantity=qty, ) total_amount = service_item.get_total_amount() request = IncomeRequest( diff --git a/config/settings.py b/config/settings.py index 12fa831..2d70618 100644 --- a/config/settings.py +++ b/config/settings.py @@ -54,6 +54,14 @@ class Settings(BaseSettings): default=None, description="Password for nalog.ru (self-employed) authentication" ) + NALOGO_RECEIPT_NAME_SUBSCRIPTION: str = Field( + default="subscription {months} months", + description="Receipt item name for time-based subscriptions. Use {months} placeholder for duration." + ) + NALOGO_RECEIPT_NAME_TRAFFIC: str = Field( + default="traffic package {gb} GB", + description="Receipt item name for traffic packages. Use {gb} placeholder for traffic amount." + ) WEBHOOK_BASE_URL: Optional[str] = None