Skip to content

Commit 42d2725

Browse files
Hugo Osvaldo BarreraWhyNotHugo
authored andcommitted
Use django helper to import variants
1 parent 6db4b0c commit 42d2725

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

payments/core.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import re
2-
from importlib import import_module
32
from typing import TYPE_CHECKING
43
from typing import Dict
54
from typing import Optional
@@ -155,9 +154,7 @@ def _default_provider_factory(variant: str, payment: Optional["BasePayment"] = N
155154
if not handler:
156155
raise ValueError("Payment variant does not exist: {}".format(variant))
157156
if variant not in PROVIDER_CACHE:
158-
module_path, class_name = handler.rsplit(".", 1)
159-
module = import_module(module_path)
160-
class_ = getattr(module, class_name)
157+
class_ = import_string(handler)
161158
PROVIDER_CACHE[variant] = class_(**config)
162159
return PROVIDER_CACHE[variant]
163160

0 commit comments

Comments
 (0)