fix: remove non-existent Platega method code 10, rename 11 to Карты (RUB)
Platega API defines: 2=СБП, 11=Карточный эквайринг, 12=Международная, 13=Крипто. Code 10 does not exist in their API but was defined in our config as "Банковские карты (RUB)", while real code 11 was mislabeled as "Банковские карты". This caused two card options to appear in the admin panel, one of which didn't work. - Removed code 10 from definitions, defaults, allowed set, .env.example - Renamed code 11: "Банковские карты" → "Карты (RUB)" - Removed redundant filter in handlers/balance/platega.py - Updated tests to match
This commit is contained in:
+1
-1
@@ -614,7 +614,7 @@ PLATEGA_RETURN_URL=
|
||||
PLATEGA_FAILED_URL=
|
||||
PLATEGA_CURRENCY=RUB
|
||||
# Список ID активных методов из кабинета Platega (через запятую)
|
||||
PLATEGA_ACTIVE_METHODS=2,10,11,12,13
|
||||
PLATEGA_ACTIVE_METHODS=2,11,12,13
|
||||
PLATEGA_MIN_AMOUNT_KOPEKS=100
|
||||
PLATEGA_MAX_AMOUNT_KOPEKS=100000000
|
||||
PLATEGA_WEBHOOK_PATH=/platega-webhook
|
||||
|
||||
+3
-4
@@ -467,7 +467,7 @@ class Settings(BaseSettings):
|
||||
PLATEGA_RETURN_URL: str | None = None
|
||||
PLATEGA_FAILED_URL: str | None = None
|
||||
PLATEGA_CURRENCY: str = 'RUB'
|
||||
PLATEGA_ACTIVE_METHODS: str = '2,10,11,12,13'
|
||||
PLATEGA_ACTIVE_METHODS: str = '2,11,12,13'
|
||||
PLATEGA_INLINE_METHODS: bool = True
|
||||
PLATEGA_MIN_AMOUNT_KOPEKS: int = 10000
|
||||
PLATEGA_MAX_AMOUNT_KOPEKS: int = 100000000
|
||||
@@ -1839,7 +1839,7 @@ class Settings(BaseSettings):
|
||||
except ValueError:
|
||||
logger.warning('Некорректный код метода Platega', part=part)
|
||||
continue
|
||||
if method_code in {2, 10, 11, 12, 13} and method_code not in seen:
|
||||
if method_code in {2, 11, 12, 13} and method_code not in seen:
|
||||
methods.append(method_code)
|
||||
seen.add(method_code)
|
||||
|
||||
@@ -1852,8 +1852,7 @@ class Settings(BaseSettings):
|
||||
def get_platega_method_definitions() -> dict[int, dict[str, str]]:
|
||||
return {
|
||||
2: {'name': 'СБП (QR)', 'title': '🏦 СБП (QR)'},
|
||||
10: {'name': 'Банковские карты (RUB)', 'title': '💳 Карты (RUB)'},
|
||||
11: {'name': 'Банковские карты', 'title': '💳 Банковские карты'},
|
||||
11: {'name': 'Карты (RUB)', 'title': '💳 Карты (RUB)'},
|
||||
12: {'name': 'Международные карты', 'title': '🌍 Международные карты'},
|
||||
13: {'name': 'Криптовалюта', 'title': '🪙 Криптовалюта'},
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
def _get_active_methods() -> list[int]:
|
||||
methods = settings.get_platega_active_methods()
|
||||
return [code for code in methods if code in {2, 10, 11, 12, 13}]
|
||||
return settings.get_platega_active_methods()
|
||||
|
||||
|
||||
async def _prompt_amount(
|
||||
|
||||
@@ -114,7 +114,7 @@ async def test_create_platega_payment_success(monkeypatch: pytest.MonkeyPatch) -
|
||||
amount_kopeks=50_000,
|
||||
description='Пополнение счёта',
|
||||
language='ru',
|
||||
payment_method_code=10,
|
||||
payment_method_code=11,
|
||||
)
|
||||
|
||||
assert result is not None
|
||||
@@ -125,9 +125,9 @@ async def test_create_platega_payment_success(monkeypatch: pytest.MonkeyPatch) -
|
||||
assert 'correlation_id' in result and len(result['correlation_id']) == 32
|
||||
assert captured_args['user_id'] == 42
|
||||
assert captured_args['amount_kopeks'] == 50_000
|
||||
assert captured_args['payment_method_code'] == 10
|
||||
assert captured_args['metadata']['selected_method'] == 10
|
||||
assert stub.calls and stub.calls[0]['payment_method'] == 10
|
||||
assert captured_args['payment_method_code'] == 11
|
||||
assert captured_args['metadata']['selected_method'] == 11
|
||||
assert stub.calls and stub.calls[0]['payment_method'] == 11
|
||||
assert stub.calls[0]['amount'] == pytest.approx(500.0)
|
||||
assert stub.calls[0]['currency'] == 'RUB'
|
||||
assert captured_args['metadata']['language'] == 'ru'
|
||||
@@ -209,13 +209,13 @@ def test_get_platega_active_methods_parses_and_filters(monkeypatch: pytest.Monke
|
||||
monkeypatch.setattr(
|
||||
settings,
|
||||
'PLATEGA_ACTIVE_METHODS',
|
||||
' 2,10, 11 ;12,13,13,invalid ',
|
||||
' 2, 11 ;12,13,13,invalid ',
|
||||
raising=False,
|
||||
)
|
||||
|
||||
methods = settings.get_platega_active_methods()
|
||||
|
||||
assert methods == [2, 10, 11, 12, 13]
|
||||
assert methods == [2, 11, 12, 13]
|
||||
|
||||
|
||||
def test_get_platega_active_methods_returns_default(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
@@ -227,7 +227,7 @@ def test_get_platega_active_methods_returns_default(monkeypatch: pytest.MonkeyPa
|
||||
|
||||
|
||||
def test_platega_method_display_helpers() -> None:
|
||||
assert settings.get_platega_method_display_name(10) == 'Банковские карты (RUB)'
|
||||
assert settings.get_platega_method_display_title(10) == '💳 Карты (RUB)'
|
||||
assert settings.get_platega_method_display_name(11) == 'Карты (RUB)'
|
||||
assert settings.get_platega_method_display_title(11) == '💳 Карты (RUB)'
|
||||
assert settings.get_platega_method_display_name(999) == 'Метод 999'
|
||||
assert settings.get_platega_method_display_title(999) == 'Platega 999'
|
||||
|
||||
Reference in New Issue
Block a user