16 lines
753 B
Python
16 lines
753 B
Python
from typing import Type
|
|
|
|
from evibes.utils.misc import create_object
|
|
from engine.payments.gateways import AbstractGateway
|
|
from engine.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
|