mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-03-04 04:43:21 +00:00
Revert "Fix Pal24 custom payload serialization"
This commit is contained in:
@@ -5,8 +5,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
import json
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from app.config import settings
|
||||
from app.external.pal24_client import Pal24Client, Pal24APIError
|
||||
@@ -36,7 +35,7 @@ class Pal24Service:
|
||||
order_id: str,
|
||||
description: str,
|
||||
ttl_seconds: Optional[int] = None,
|
||||
custom_payload: Optional[Union[Dict[str, Any], str]] = None,
|
||||
custom_payload: Optional[Dict[str, Any]] = None,
|
||||
payer_email: Optional[str] = None,
|
||||
payment_method: Optional[str] = None,
|
||||
) -> Dict[str, Any]:
|
||||
@@ -44,22 +43,10 @@ class Pal24Service:
|
||||
raise Pal24APIError("Pal24 service is not configured")
|
||||
|
||||
amount_decimal = Pal24Client.normalize_amount(amount_kopeks)
|
||||
extra_payload: Dict[str, Any] = {"ttl": ttl_seconds}
|
||||
|
||||
if custom_payload is not None:
|
||||
if isinstance(custom_payload, str):
|
||||
extra_payload["custom"] = custom_payload
|
||||
else:
|
||||
try:
|
||||
extra_payload["custom"] = json.dumps(
|
||||
custom_payload,
|
||||
ensure_ascii=False,
|
||||
separators=(",", ":"),
|
||||
)
|
||||
except (TypeError, ValueError) as error:
|
||||
raise Pal24APIError(
|
||||
"Unable to serialize Pal24 custom payload to JSON"
|
||||
) from error
|
||||
extra_payload: Dict[str, Any] = {
|
||||
"custom": custom_payload or {},
|
||||
"ttl": ttl_seconds,
|
||||
}
|
||||
|
||||
if payer_email:
|
||||
extra_payload["payer_email"] = payer_email
|
||||
|
||||
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional
|
||||
import sys
|
||||
@@ -78,7 +77,6 @@ async def test_create_bill_success(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
assert client.calls and client.calls[0]["amount"] == Decimal("500.00")
|
||||
assert client.calls[0]["shop_id"] == "shop42"
|
||||
assert client.calls[0]["description"] == "Пополнение"
|
||||
assert client.calls[0]["custom"] == json.dumps({"extra": "value"}, ensure_ascii=False, separators=(",", ":"))
|
||||
|
||||
|
||||
@pytest.mark.anyio("asyncio")
|
||||
|
||||
Reference in New Issue
Block a user