From af293907d6bd06d7b6b7319e533c46852e2c17e9 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 fb3be853e..4995077f0 100644 --- a/payments/core.py +++ b/payments/core.py @@ -1,5 +1,4 @@ import re -from importlib import import_module from typing import TYPE_CHECKING from typing import Dict from typing import Optional @@ -155,9 +154,7 @@ def _default_provider_factory(variant: str, payment: Optional["BasePayment"] = N 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]