From b77385d80f66cd9771a5d7b7da3b2e1c926fc782 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Mon, 11 Apr 2022 23:16:16 +0200 Subject: [PATCH] Use django helper to import variants --- payments/core.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/payments/core.py b/payments/core.py index 6fce7725d..16e371e26 100644 --- a/payments/core.py +++ b/payments/core.py @@ -1,7 +1,6 @@ from __future__ import annotations import re -from importlib import import_module from typing import TYPE_CHECKING from urllib.parse import urlencode from urllib.parse import urljoin @@ -167,9 +166,7 @@ def _default_provider_factory(variant: str, payment: BasePayment | None = None): if not handler: raise ValueError(f"Payment variant does not exist: {variant}") if variant not in PROVIDER_CACHE: - module_path, class_name = handler.rsplit(".", 1) - module = import_module(module_path) - class_ = getattr(module, class_name) + class_ = import_string(handler) PROVIDER_CACHE[variant] = class_(**config) return PROVIDER_CACHE[variant]