Skip to content

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

Use gateway enum instead of str

Jakub Draganek5cbaa4a15182
diff --git a/saleor/core/payments.py b/saleor/core/payments.py
index aff54801a5..2726cac06d 100644
--- a/saleor/core/payments.py
+++ b/saleor/core/payments.py
@@ -1,44 +1,57 @@
from abc import ABC, abstractmethod
+from enum import Enum
from typing import TYPE_CHECKING, List
if TYPE_CHECKING:
from saleor.payment.interface import PaymentData, GatewayResponse, CustomerSource
+class Gateway(Enum):
+ """Possible gateway values.
+
+ TODO: Create this in runtime based on available plugins
+ """
+
+ DUMMY = "dummy"
+ BRAINTREE = "braintree"
+ RAZORPAY = "razorpay"
+ STRIPE = "stripe"
+
+
class PaymentInterface(ABC):
@abstractmethod
def authorize_payment(
- self, gateway: str, payment_information: "PaymentData"
+ self, gateway: Gateway, payment_information: "PaymentData"
) -> "GatewayResponse":
pass
@abstractmethod
def capture_payment(
- self, gateway: str, payment_information: "PaymentData"
+ self, gateway: Gateway, payment_information: "PaymentData"
) -> "GatewayResponse":
pass
@abstractmethod
def refund_payment(
- self, gateway: str, payment_information: "PaymentData"
+ self, gateway: Gateway, payment_information: "PaymentData"
) -> "GatewayResponse":
pass
@abstractmethod
def void_payment(
- self, gateway: str, payment_information: "PaymentData"
+ self, gateway: Gateway, payment_information: "PaymentData"
) -> "GatewayResponse":
pass
@abstractmethod
def confirm_payment(
- self, gateway: str, payment_information: "PaymentData"
+ self, gateway: Gateway, payment_information: "PaymentData"
) -> "GatewayResponse":
pass
@abstractmethod
def process_payment(
- self, gateway: str, payment_information: "PaymentData"
+ self, gateway: Gateway, payment_information: "PaymentData"
) -> "GatewayResponse":
pass