Features: 1) Add match-case logic for selecting gateway in process_transaction_changes.

Fixes: None.

Extra: 1) Minor adjustment to default `AbstractGateway` instantiation.
This commit is contained in:
Egor Pavlovich Gorbunov 2025-06-30 18:51:49 +03:00
parent 1e2b64514b
commit 4efaeaea8f

View file

@ -17,7 +17,13 @@ def create_balance_on_user_creation_signal(instance, created, **_kwargs):
def process_transaction_changes(instance, created, **_kwargs):
if created:
try:
gateway = AbstractGateway()
match instance.process.get("gateway", "default"):
case "gateway":
gateway = AbstractGateway
case "default":
gateway = AbstractGateway
case _:
gateway = AbstractGateway()
gateway.process_transaction(instance)
except Exception as e: # noqa:
instance.process = {"status": "NOGATEWAY", "error": str(e)}