schon/payments/utils/gateways.py
Egor fureunoir Gorbunov 6fa037390c Features: 1) Add get_gateways_integrations utility for payment gateway integrations; 2) Add get_vendors_integrations utility for vendor integrations; 3) Add version API endpoint to return eVibes version; 4) Implement __str__ method for AbstractVendor;
Fixes: 1) Update return type of `create_object` to `Any`;

Extra: 1) Remove unused fields (`icon`, `priority`, `hide`) from `blog.apps`; 2) Update API URLs to include `version` endpoint; 3) Miscellaneous cleanup and comments.
2025-10-15 14:25:10 +03:00

16 lines
739 B
Python

from typing import Type
from evibes.utils.misc import create_object
from payments.gateways import AbstractGateway
from payments.models import Gateway
def get_gateways_integrations(name: str | None = None) -> list[Type[AbstractGateway]]:
gateways_integrations: list[Type[AbstractGateway]] = []
gateways = Gateway.objects.filter(is_active=True, name=name) if name else Gateway.objects.filter(is_active=True)
for gateway in gateways:
if gateway.integration_path:
module_name = ".".join(gateway.integration_path.split(".")[:-1])
class_name = gateway.integration_path.split(".")[-1]
gateways_integrations.append(create_object(module_name, class_name))
return gateways_integrations