Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move availablePaymentGateways to checkout query
fowczarek1714fcdfc6b2
diff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.pyindex 9c0682d339..63a16772da 100644--- a/saleor/graphql/checkout/types.py+++ b/saleor/graphql/checkout/types.py@@ -1,11 +1,13 @@import grapheneimport graphene_django_optimizer as gql_optimizer+from django.conf import settingsfrom ...checkout import modelsfrom ...core.utils.taxes import get_taxes_for_addressfrom ..core.connection import CountableDjangoObjectTypefrom ..core.types.money import TaxedMoneyfrom ..order.utils import applicable_shipping_methods+from ..payment.enums import PaymentGatewayEnumfrom ..shipping.types import ShippingMethod@@ -36,6 +38,9 @@ class Checkout(CountableDjangoObjectType):available_shipping_methods = graphene.List(ShippingMethod, required=False,description='Shipping methods that can be used with this order.')+ available_payment_gateways = graphene.List(+ PaymentGatewayEnum, description='List of available payment gateways.',+ required=True)is_shipping_required = graphene.Boolean(description='Returns True, if checkout requires shipping.',required=True)@@ -86,5 +91,8 @@ class Checkout(CountableDjangoObjectType):taxes=taxes, discounts=info.context.discounts)return applicable_shipping_methods(self, info, price.gross.amount)+ def resolve_available_payment_gateways(self, info):+ return settings.CHECKOUT_PAYMENT_GATEWAYS.keys()+def resolve_is_shipping_required(self, info):return self.is_shipping_required()diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.pyindex fa51770d00..b5abf085a7 100644--- a/saleor/graphql/shop/types.py+++ b/saleor/graphql/shop/types.py@@ -17,7 +17,6 @@ from ..core.enums import WeightUnitsEnumfrom ..core.types.common import (CountryDisplay, LanguageDisplay, PermissionDisplay)from ..menu.types import Menu-from ..payment.enums import PaymentGatewayEnumfrom ..product.types import Collectionfrom ..utils import format_permissions_for_displayfrom .enums import AuthorizationKeyType@@ -77,9 +76,6 @@ class Shop(graphene.ObjectType):required=True)default_currency = graphene.String(description='Default shop\'s currency.', required=True)- available_payment_gateways = graphene.List(- PaymentGatewayEnum, description='List of available payment gateways.',- required=True)default_country = graphene.Field(CountryDisplay, description='Default shop\'s country')description = graphene.String(description='Shop\'s description.')@@ -148,9 +144,6 @@ class Shop(graphene.ObjectType):def resolve_default_currency(self, info):return settings.DEFAULT_CURRENCY- def resolve_available_payment_gateways(self, info):- return settings.CHECKOUT_PAYMENT_GATEWAYS.keys()-def resolve_description(self, info):return info.context.site.settings.descriptiondiff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex a69cc2bdea..8bfad3c460 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -7,6 +7,7 @@ from tests.api.utils import get_graphql_contentfrom saleor.checkout.models import Cartfrom saleor.checkout.utils import is_fully_paid, ready_to_place_order+from saleor.graphql.core.utils import str_to_enumfrom saleor.order.models import OrderMUTATION_CHECKOUT_CREATE = """@@ -162,6 +163,24 @@ def test_checkout_create_check_lines_quantity(assert data['errors'][0]['field'] == 'quantity'+def test_checkout_available_payment_gateways(+ api_client, cart_with_item, settings):+ query = """+ query getCheckout($token: UUID!) {+ checkout(token: $token) {+ availablePaymentGateways+ }+ }+ """+ variables = {'token': str(cart_with_item.token)}+ response = api_client.post_graphql(query, variables)+ content = get_graphql_content(response)+ data = content['data']['checkout']+ checkout_payment_gateways = [+ str_to_enum(gateway) for gateway in settings.CHECKOUT_PAYMENT_GATEWAYS.keys()]+ assert data['availablePaymentGateways'] == checkout_payment_gateways++MUTATION_CHECKOUT_LINES_ADD = """mutation checkoutLinesAdd($checkoutId: ID!, $lines: [CheckoutLineInput!]!) {checkoutLinesAdd(checkoutId: $checkoutId, lines: $lines) {diff --git a/tests/api/test_shop.py b/tests/api/test_shop.pyindex 78d4508678..c02ae0466c 100644--- a/tests/api/test_shop.py+++ b/tests/api/test_shop.py@@ -512,20 +512,3 @@ def test_shop_fetch_tax_rates(MUTATION_SHOP_FETCH_TAX_RATES)get_graphql_content(response)mock_call_command.assert_called_once_with('get_vat_rates')---def test_shop_available_payment_gateways(- api_client, settings):- query = """- query {- shop {- availablePaymentGateways- }- }- """- response = api_client.post_graphql(query)- content = get_graphql_content(response)- data = content['data']['shop']- checkout_payment_gateways = [- str_to_enum(gateway) for gateway in settings.CHECKOUT_PAYMENT_GATEWAYS.keys()]- assert data['availablePaymentGateways'] == checkout_payment_gateways