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 Oct 19, 2023
1 parent 71aecca commit b77385d
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,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
Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit b77385d

Please sign in to comment.