Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add checkout to list_payment_gateways
Marcin Gębala2ac47e551888
diff --git a/saleor/core/payments.py b/saleor/core/payments.pyindex fc0d2bdcc3..acf3b689ad 100644--- a/saleor/core/payments.py+++ b/saleor/core/payments.py@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, List, Optionalif TYPE_CHECKING:# flake8: noqa+ from ..checkout.models import Checkoutfrom ..payment.interface import (CustomerSource,GatewayResponse,@@ -17,6 +18,7 @@ class PaymentInterface(ABC):def list_payment_gateways(self,currency: Optional[str] = None,+ checkout: Optional["Checkout"] = None,active_only: bool = True,) -> List["PaymentGateway"]:passdiff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.pyindex a869ea6ff8..4a1fa13ee8 100644--- a/saleor/graphql/checkout/types.py+++ b/saleor/graphql/checkout/types.py@@ -425,7 +425,9 @@ class Checkout(CountableDjangoObjectType):@staticmethoddef resolve_available_payment_gateways(root: models.Checkout, info):- return info.context.plugins.list_payment_gateways(currency=root.currency)+ return info.context.plugins.list_payment_gateways(+ currency=root.currency, checkout=root+ )@staticmethoddef resolve_gift_cards(root: models.Checkout, _info):diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.pyindex 9adf3e5eaa..81c45ae043 100644--- a/saleor/plugins/manager.py+++ b/saleor/plugins/manager.py@@ -595,6 +595,7 @@ class PluginsManager(PaymentInterface):def list_payment_gateways(self,currency: Optional[str] = None,+ checkout: Optional["Checkout"] = None,active_only: bool = True,) -> List["PaymentGateway"]:payment_plugins = self.list_payment_plugin(active_only=active_only)@@ -603,7 +604,7 @@ class PluginsManager(PaymentInterface):for plugin in payment_plugins.values():gateways.extend(plugin.get_payment_gateways(- currency=currency, checkout=None, previous_value=None+ currency=currency, checkout=checkout, previous_value=None))return gateways