Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Create PaymentInterface

Jakub Draganek26c3b576766e
diff --git a/saleor/core/payments.py b/saleor/core/payments.py
new file mode 100644
index 0000000000..aff54801a5
--- /dev/null
+++ b/saleor/core/payments.py
@@ -0,0 +1,47 @@
+from abc import ABC, abstractmethod
+from typing import TYPE_CHECKING, List
+
+if TYPE_CHECKING:
+ from saleor.payment.interface import PaymentData, GatewayResponse, CustomerSource
+
+
+class PaymentInterface(ABC):
+ @abstractmethod
+ def authorize_payment(
+ self, gateway: str, payment_information: "PaymentData"
+ ) -> "GatewayResponse":
+ pass
+
+ @abstractmethod
+ def capture_payment(
+ self, gateway: str, payment_information: "PaymentData"
+ ) -> "GatewayResponse":
+ pass
+
+ @abstractmethod
+ def refund_payment(
+ self, gateway: str, payment_information: "PaymentData"
+ ) -> "GatewayResponse":
+ pass
+
+ @abstractmethod
+ def void_payment(
+ self, gateway: str, payment_information: "PaymentData"
+ ) -> "GatewayResponse":
+ pass
+
+ @abstractmethod
+ def confirm_payment(
+ self, gateway: str, payment_information: "PaymentData"
+ ) -> "GatewayResponse":
+ pass
+
+ @abstractmethod
+ def process_payment(
+ self, gateway: str, payment_information: "PaymentData"
+ ) -> "GatewayResponse":
+ pass
+
+ @abstractmethod
+ def list_payment_sources(self, customer_id: str) -> List["CustomerSource"]:
+ pass
diff --git a/saleor/extensions/manager.py b/saleor/extensions/manager.py
index 487687d24e..a999875d09 100644
--- a/saleor/extensions/manager.py
+++ b/saleor/extensions/manager.py
@@ -6,6 +6,7 @@ from django.utils.module_loading import import_string
from django_countries.fields import Country
from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRange
+from ..core.payments import PaymentInterface
from ..core.taxes import TaxType, quantize_price
from .models import PluginConfiguration
@@ -18,7 +19,7 @@ if TYPE_CHECKING:
from ..payment.interface import PaymentData, GatewayResponse, CustomerSource
-class ExtensionsManager:
+class ExtensionsManager(PaymentInterface):
"""Base manager for handling plugins logic."""
plugins = None