Skip to content

Commit

Permalink
Use django helper to import variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Osvaldo Barrera authored and WhyNotHugo committed May 25, 2023
1 parent 6db4b0c commit 42d2725
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions payments/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
from importlib import import_module
from typing import TYPE_CHECKING
from typing import Dict
from typing import Optional
Expand Down Expand Up @@ -155,9 +154,7 @@ def _default_provider_factory(variant: str, payment: Optional["BasePayment"] = N
if not handler:
raise ValueError("Payment variant does not exist: {}".format(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]

Expand Down

0 comments on commit 42d2725

Please sign in to comment.