Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove Gateway enum and use string instead
Jakub Draganek7c34aae2afa6
diff --git a/saleor/core/payments.py b/saleor/core/payments.pyindex 8088e68731..b32491f2a4 100644--- a/saleor/core/payments.py+++ b/saleor/core/payments.py@@ -1,80 +1,67 @@from abc import ABC, abstractmethod-from enum import Enumfrom typing import TYPE_CHECKING, Listif TYPE_CHECKING:from saleor.payment.interface import PaymentData, GatewayResponse, TokenConfig-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 list_payment_gateways(self) -> List[Gateway]:+ def list_payment_gateways(self) -> List[str]:pass@abstractmethoddef authorize_payment(- self, gateway: Gateway, payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> "GatewayResponse":pass@abstractmethoddef capture_payment(- self, gateway: Gateway, payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> "GatewayResponse":pass@abstractmethoddef refund_payment(- self, gateway: Gateway, payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> "GatewayResponse":pass@abstractmethoddef void_payment(- self, gateway: Gateway, payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> "GatewayResponse":pass@abstractmethoddef confirm_payment(- self, gateway: Gateway, payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> "GatewayResponse":pass@abstractmethoddef process_payment(- self, gateway: Gateway, payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> "GatewayResponse":pass@abstractmethoddef create_payment_form(- self, data, gateway: Gateway, payment_information: "PaymentData"+ self, data, gateway: str, payment_information: "PaymentData") -> "GatewayResponse":pass@abstractmethod- def get_client_token(self, gateway: Gateway, token_config: "TokenConfig") -> str:+ def get_client_token(self, gateway: str, token_config: "TokenConfig") -> str:pass@abstractmethoddef list_payment_sources(- self, gateway: Gateway, customer_id: str+ self, gateway: str, customer_id: str) -> List["CustomerSource"]:pass@abstractmethod- def get_payment_template(self, gateway: Gateway) -> str:+ def get_payment_template(self, gateway: str) -> str:passdiff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex 7f685e7573..bd077afac1 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -373,7 +373,7 @@ def create_fake_user():@patch("saleor.order.emails.send_payment_confirmation.delay")def create_fake_payment(mock_email_confirmation, order):payment = create_payment(- gateway=settings.DUMMY,+ gateway="Dummy",customer_ip_address=fake.ipv4(),email=order.user_email,order=order,diff --git a/saleor/extensions/manager.py b/saleor/extensions/manager.pyindex 49718ba2bf..3975989ae7 100644--- a/saleor/extensions/manager.py+++ b/saleor/extensions/manager.py@@ -13,7 +13,6 @@ from .models import PluginConfigurationif TYPE_CHECKING:from .base_plugin import BasePluginfrom ..checkout.models import Checkout, CheckoutLine- from ..core.payments import Gatewayfrom ..product.models import Productfrom ..account.models import Addressfrom ..order.models import OrderLine, Order@@ -182,37 +181,37 @@ class ExtensionsManager(PaymentInterface):)def authorize_payment(- self, gateway: "Gateway", payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> Optional["GatewayResponse"]:method_name = "authorize_payment"return self.__run_payment_method(gateway, method_name, payment_information)def capture_payment(- self, gateway: "Gateway", payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> Optional["GatewayResponse"]:method_name = "capture_payment"return self.__run_payment_method(gateway, method_name, payment_information)def refund_payment(- self, gateway: "Gateway", payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> Optional["GatewayResponse"]:method_name = "refund_payment"return self.__run_payment_method(gateway, method_name, payment_information)def void_payment(- self, gateway: "Gateway", payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> Optional["GatewayResponse"]:method_name = "void_payment"return self.__run_payment_method(gateway, method_name, payment_information)def confirm_payment(- self, gateway: "Gateway", payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> Optional["GatewayResponse"]:method_name = "confirm_payment"return self.__run_payment_method(gateway, method_name, payment_information)def process_payment(- self, gateway: "Gateway", payment_information: "PaymentData"+ self, gateway: str, payment_information: "PaymentData") -> Optional["GatewayResponse"]:method_name = "process_payment"return self.__run_payment_method(gateway, method_name, payment_information)@@ -226,23 +225,21 @@ class ExtensionsManager(PaymentInterface):def get_client_token(self, gateway, token_config: "TokenConfig") -> str:method_name = "get_client_token"default_value = None- gateway_name = gateway.value- gtw = self.get_plugin(gateway_name)+ gtw = self.get_plugin(gateway)return self.__run_method_on_single_plugin(gtw, method_name, default_value, token_config=token_config)def list_payment_sources(- self, gateway: "Gateway", customer_id: str+ self, gateway: str, customer_id: str) -> List["CustomerSource"]:default_value = []- gateway_name = gateway.value- gtw = self.get_plugin(gateway_name)+ gtw = self.get_plugin(gateway)if gtw is not None:return self.__run_method_on_single_plugin(gtw, "list_payment_sources", default_value, customer_id=customer_id)- raise Exception(f"Payment plugin {gateway_name} is inaccessible!")+ raise Exception(f"Payment plugin {gateway} is inaccessible!")def list_payment_gateways(self) -> List[str]:payment_method = "process_payment"@@ -253,23 +250,21 @@ class ExtensionsManager(PaymentInterface):and self.get_plugin_configuration(plugin.PLUGIN_NAME).active]- def get_payment_template(self, gateway: "Gateway") -> str:+ def get_payment_template(self, gateway: str) -> str:method_name = "get_payment_template"default_value = None- gateway_name = gateway.value- gtw = self.get_plugin(gateway_name)+ gtw = self.get_plugin(gateway)return self.__run_method_on_single_plugin(gtw, method_name, default_value)def __run_payment_method(self,- gateway: "Gateway",+ gateway: str,method_name: str,payment_information: "PaymentData",**kwargs,) -> Optional["GatewayResposne"]:default_value = None- gateway_name = gateway.value- gtw = self.get_plugin(gateway_name)+ gtw = self.get_plugin(gateway)if gtw is not None:resp = self.__run_method_on_single_plugin(gtw,@@ -282,7 +277,7 @@ class ExtensionsManager(PaymentInterface):return respraise Exception(- f"Payment plugin {gateway_name} for {method_name}"+ f"Payment plugin {gateway} for {method_name}"" payment method is inaccessible!")diff --git a/saleor/graphql/account/resolvers.py b/saleor/graphql/account/resolvers.pyindex cb9dfa3f46..cbae098cda 100644--- a/saleor/graphql/account/resolvers.py+++ b/saleor/graphql/account/resolvers.py@@ -94,7 +94,7 @@ def resolve_address_validation_rules(def resolve_payment_sources(user: models.User):stored_customer_accounts = (- (gtw, fetch_customer_id(user, gtw.value)) for gtw in gateway.list_gateways()+ (gtw, fetch_customer_id(user, gtw)) for gtw in gateway.list_gateways())return list(chain(diff --git a/saleor/graphql/payment/resolvers.py b/saleor/graphql/payment/resolvers.pyindex e70557b561..7645c2fe90 100644--- a/saleor/graphql/payment/resolvers.py+++ b/saleor/graphql/payment/resolvers.py@@ -1,6 +1,5 @@import graphene_django_optimizer as gql_optimizer-from ...core.payments import Gatewayfrom ...payment import gateway as payment_gateway, modelsfrom ...payment.utils import fetch_customer_idfrom ..utils import filter_by_query_param@@ -8,9 +7,9 @@ from ..utils import filter_by_query_paramPAYMENT_SEARCH_FIELDS = ["id"]-def resolve_client_token(user, gateway):+def resolve_client_token(user, gateway: str):customer_id = fetch_customer_id(user, gateway)- return payment_gateway.get_client_token(Gateway(gateway), customer_id)+ return payment_gateway.get_client_token(gateway, customer_id)def resolve_payments(info, query):diff --git a/saleor/order/views.py b/saleor/order/views.pyindex fa07e3ae78..656edb1f7f 100644--- a/saleor/order/views.py+++ b/saleor/order/views.py@@ -12,7 +12,6 @@ from django.views.decorators.csrf import csrf_exemptfrom ..account.forms import LoginFormfrom ..account.models import User-from ..core.payments import Gatewayfrom ..core.utils import get_client_ipfrom ..payment import ChargeStatus, TransactionKind, gateway as payment_gatewayfrom ..payment.utils import create_payment, fetch_customer_id@@ -122,8 +121,7 @@ def start_payment(request, order, gateway):return redirect(order.get_absolute_url())client_token = payment_gateway.get_client_token(- Gateway(payment.gateway),- customer_id=fetch_customer_id(request.user, payment.gateway),+ payment.gateway, customer_id=fetch_customer_id(request.user, payment.gateway))ctx = {"form": form,@@ -131,7 +129,7 @@ def start_payment(request, order, gateway):"client_token": client_token,"order": order,}- template_path = payment_gateway.get_template_path(Gateway(payment.gateway))+ template_path = payment_gateway.get_template_path(payment.gateway)return TemplateResponse(request, template_path, ctx)diff --git a/saleor/payment/gateway.py b/saleor/payment/gateway.pyindex c271c5d86f..ecddd128eb 100644--- a/saleor/payment/gateway.py+++ b/saleor/payment/gateway.py@@ -3,9 +3,7 @@ from decimal import Decimalfrom typing import Listfrom django import forms-from django.core.exceptions import ImproperlyConfigured-from ..core.payments import Gatewayfrom ..extensions.manager import get_extensions_managerfrom ..payment.interface import TokenConfigfrom . import GatewayError, PaymentError, TransactionKind@@ -60,12 +58,11 @@ def process_payment(payment: Payment, token: str, store_source: bool = False) -> Transaction:plugin_manager = get_extensions_manager()- gateway = _get_gateway(payment)payment_data = create_payment_information(payment=payment, payment_token=token, store_source=store_source)response, error = _fetch_gateway_response(- plugin_manager.process_payment, gateway, payment_data+ plugin_manager.process_payment, payment.gateway, payment_data)return create_transaction(payment=payment,@@ -82,12 +79,11 @@ def process_payment(def authorize(payment: Payment, token: str, store_source: bool = False) -> Transaction:plugin_manager = get_extensions_manager()clean_authorize(payment)- gateway = _get_gateway(payment)payment_data = create_payment_information(payment=payment, payment_token=token, store_source=store_source)response, error = _fetch_gateway_response(- plugin_manager.authorize_payment, gateway, payment_data+ plugin_manager.authorize_payment, payment.gateway, payment_data)return create_transaction(payment=payment,@@ -108,13 +104,12 @@ def capture(if amount is None:amount = payment.get_charge_amount()clean_capture(payment, Decimal(amount))- gateway = _get_gateway(payment)token = _get_past_transaction_token(payment, TransactionKind.AUTH)payment_data = create_payment_information(payment=payment, payment_token=token, amount=amount, store_source=store_source)response, error = _fetch_gateway_response(- plugin_manager.capture_payment, gateway, payment_data+ plugin_manager.capture_payment, payment.gateway, payment_data)if response.card_info:update_card_details(payment, response)@@ -137,13 +132,12 @@ def refund(payment: Payment, amount: Decimal = None) -> Transaction:_validate_refund_amound(payment, amount)if not payment.can_refund():raise PaymentError("This payment cannot be refunded.")- gateway = _get_gateway(payment)token = _get_past_transaction_token(payment, TransactionKind.CAPTURE)payment_data = create_payment_information(payment=payment, payment_token=token, amount=amount)response, error = _fetch_gateway_response(- plugin_manager.refund_payment, gateway, payment_data+ plugin_manager.refund_payment, payment.gateway, payment_data)return create_transaction(payment=payment,@@ -159,11 +153,10 @@ def refund(payment: Payment, amount: Decimal = None) -> Transaction:@require_active_paymentdef void(payment: Payment) -> Transaction:plugin_manager = get_extensions_manager()- gateway = _get_gateway(payment)token = _get_past_transaction_token(payment, TransactionKind.AUTH)payment_data = create_payment_information(payment=payment, payment_token=token)response, error = _fetch_gateway_response(- plugin_manager.void_payment, gateway, payment_data+ plugin_manager.void_payment, payment.gateway, payment_data)return create_transaction(payment=payment,@@ -179,11 +172,10 @@ def void(payment: Payment) -> Transaction:@require_active_paymentdef confirm(payment: Payment) -> Transaction:plugin_manager = get_extensions_manager()- gateway = _get_gateway(payment)token = _get_past_transaction_token(payment, TransactionKind.AUTH)payment_data = create_payment_information(payment=payment, payment_token=token)response, error = _fetch_gateway_response(- plugin_manager.confirm_payment, gateway, payment_data+ plugin_manager.confirm_payment, payment.gateway, payment_data)return create_transaction(payment=payment,@@ -198,16 +190,15 @@ def confirm(payment: Payment) -> Transaction:def create_payment_form(payment: Payment, data) -> forms.Form:plugin_manager = get_extensions_manager()payment_data = create_payment_information(payment)- gateway = _get_gateway(payment)- return plugin_manager.create_payment_form(data, gateway, payment_data)+ return plugin_manager.create_payment_form(data, payment.gateway, payment_data)-def list_payment_sources(gateway: Gateway, customer_id: str) -> List["CustomerSource"]:+def list_payment_sources(gateway: str, customer_id: str) -> List["CustomerSource"]:plugin_manager = get_extensions_manager()return plugin_manager.list_payment_sources(gateway, customer_id)-def get_client_token(gateway: Gateway, customer_id: str = None) -> str:+def get_client_token(gateway: str, customer_id: str = None) -> str:plugin_manager = get_extensions_manager()token_config = TokenConfig(customer_id=customer_id)return plugin_manager.get_client_token(gateway, token_config)@@ -217,19 +208,10 @@ def list_gateways() -> List[str]:return get_extensions_manager().list_payment_gateways()-def get_template_path(gateway: Gateway) -> str:+def get_template_path(gateway: str) -> str:return get_extensions_manager().get_payment_template(gateway)-def _get_gateway(payment: Payment) -> Gateway:- try:- gateway = Gateway(payment.gateway)- except AttributeError:- raise ImproperlyConfigured(f"Payment gateway {gateway} is not configured.")-- return gateway--def _fetch_gateway_response(fn, *args, **kwargs):response, error = None, Nonetry:diff --git a/saleor/payment/gateways/braintree/plugin.py b/saleor/payment/gateways/braintree/plugin.pyindex 8d009d1f10..98b1057ac7 100644--- a/saleor/payment/gateways/braintree/plugin.py+++ b/saleor/payment/gateways/braintree/plugin.py@@ -17,7 +17,7 @@ from . import (void,)-GATEWAY_NAME = "braintree"+GATEWAY_NAME = "Braintree"if TYPE_CHECKING:from . import GatewayResponse, PaymentData, TokenConfig@@ -36,7 +36,7 @@ def require_active_plugin(fn):class BraintreeGatewayPlugin(BasePlugin):- PLUGIN_NAME = "braintree"+ PLUGIN_NAME = GATEWAY_NAMECONFIG_STRUCTURE = {"Template path": {"type": ConfigurationTypeField.STRING,diff --git a/saleor/payment/gateways/dummy/plugin.py b/saleor/payment/gateways/dummy/plugin.pyindex e9fc0e6753..8c65e9f75b 100644--- a/saleor/payment/gateways/dummy/plugin.py+++ b/saleor/payment/gateways/dummy/plugin.py@@ -17,7 +17,7 @@ from . import (void,)-GATEWAY_NAME = "dummy"+GATEWAY_NAME = "Dummy"if TYPE_CHECKING:from ...interface import GatewayResponse, PaymentData, TokenConfigdiff --git a/saleor/payment/gateways/razorpay/plugin.py b/saleor/payment/gateways/razorpay/plugin.pyindex 8b07240bf3..5c7c33d72e 100644--- a/saleor/payment/gateways/razorpay/plugin.py+++ b/saleor/payment/gateways/razorpay/plugin.py@@ -7,7 +7,7 @@ from saleor.extensions.base_plugin import BasePluginfrom . import GatewayConfig, capture, create_form, process_payment, refund-GATEWAY_NAME = "razorpay"+GATEWAY_NAME = "Razorpay"if TYPE_CHECKING:from . import GatewayResponse, PaymentDatadiff --git a/saleor/payment/gateways/stripe/plugin.py b/saleor/payment/gateways/stripe/plugin.pyindex 292a919951..9495f89aa6 100644--- a/saleor/payment/gateways/stripe/plugin.py+++ b/saleor/payment/gateways/stripe/plugin.py@@ -15,7 +15,7 @@ from . import (void,)-GATEWAY_NAME = "stripe"+GATEWAY_NAME = "Stripe"if TYPE_CHECKING:from . import GatewayResponse, PaymentDatadiff --git a/saleor/settings.py b/saleor/settings.pyindex cb6eac1137..cf6be1562e 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -610,11 +610,6 @@ SENTRY_DSN = os.environ.get("SENTRY_DSN")if SENTRY_DSN:sentry_sdk.init(dsn=SENTRY_DSN, integrations=[DjangoIntegration()])-DUMMY = "dummy"-BRAINTREE = "braintree"-RAZORPAY = "razorpay"-STRIPE = "stripe"-GRAPHENE = {"RELAY_CONNECTION_ENFORCE_FIRST_OR_LAST": True,"RELAY_CONNECTION_MAX_LIMIT": 100,diff --git a/tests/api/benchmark/test_checkout.py b/tests/api/benchmark/test_checkout.pyindex a9d7936055..098a461396 100644--- a/tests/api/benchmark/test_checkout.py+++ b/tests/api/benchmark/test_checkout.py@@ -43,10 +43,7 @@ def checkout_with_charged_payment(checkout_with_billing_address):total = checkout.get_total()taxed_total = TaxedMoney(total, total)payment = Payment.objects.create(- gateway=settings.DUMMY,- is_active=True,- total=taxed_total.gross.amount,- currency="USD",+ gateway="Dummy", is_active=True, total=taxed_total.gross.amount, currency="USD")payment.charge_status = ChargeStatus.FULLY_CHARGED@@ -492,7 +489,7 @@ def test_checkout_payment_charge("input": {"billingAddress": graphql_address_data,"amount": 1000, # 10.00 USD * 100- "gateway": settings.DUMMY.upper(),+ "gateway": "Dummy","token": "charged",},}diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex bbcce47f8a..2059c8417f 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -391,7 +391,7 @@ def test_checkout_available_payment_gateways(api_client, checkout_with_item):response = api_client.post_graphql(query, variables)content = get_graphql_content(response)data = content["data"]["checkout"]- assert data["availablePaymentGateways"] == ["dummy"]+ assert data["availablePaymentGateways"] == ["Dummy"]def test_checkout_available_shipping_methods(diff --git a/tests/api/test_order.py b/tests/api/test_order.pyindex 3f479e5bd6..95a10a12ce 100644--- a/tests/api/test_order.py+++ b/tests/api/test_order.py@@ -1414,7 +1414,7 @@ def test_order_capture(assert event_captured.user == staff_userassert event_captured.parameters == {"amount": str(amount),- "payment_gateway": "dummy",+ "payment_gateway": "Dummy","payment_id": "",}diff --git a/tests/api/test_payment.py b/tests/api/test_payment.pyindex ec3ba34abc..9d2a385366 100644--- a/tests/api/test_payment.py+++ b/tests/api/test_payment.py@@ -4,7 +4,6 @@ import grapheneimport pytestfrom prices import TaxedMoney-from saleor.core.payments import Gatewayfrom saleor.core.utils import get_country_name_by_codefrom saleor.graphql.payment.enums import OrderAction, PaymentChargeStatusEnumfrom saleor.payment.interface import CreditCardInfo, CustomerSource, TokenConfig@@ -100,7 +99,7 @@ def test_checkout_add_payment(variables = {"checkoutId": checkout_id,"input": {- "gateway": "DUMMY",+ "gateway": "Dummy","token": "sample-token","amount": total.gross.amount,"billingAddress": graphql_address_data,@@ -131,7 +130,7 @@ def test_use_checkout_billing_address_as_payment_billing(variables = {"checkoutId": checkout_id,"input": {- "gateway": "DUMMY",+ "gateway": "Dummy","token": "sample-token","amount": total.gross.amount,},@@ -542,7 +541,7 @@ def test_list_payment_sources(source = CustomerSource(id="test1", gateway="braintree", credit_card_info=card)mocker.patch("saleor.graphql.account.resolvers.gateway.list_gateways",- return_value=[Gateway("braintree")],+ return_value=["braintree"],autospec=True,)mock_get_source_list = mocker.patch(@@ -552,9 +551,7 @@ def test_list_payment_sources()response = user_api_client.post_graphql(query)- mock_get_source_list.assert_called_once_with(- Gateway("braintree"), braintree_customer_id- )+ mock_get_source_list.assert_called_once_with("braintree", braintree_customer_id)content = get_graphql_content(response)["data"]["me"]["storedPaymentSources"]assert content is not None and len(content) == 1assert content[0] == {diff --git a/tests/conftest.py b/tests/conftest.pyindex fb9f85101b..793e6fd1ca 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1224,9 +1224,9 @@ def product_translation_fr(product):@pytest.fixture-def payment_dummy(db, settings, order_with_lines):+def payment_dummy(db, order_with_lines):return Payment.objects.create(- gateway=settings.DUMMY,+ gateway="Dummy",order=order_with_lines,is_active=True,cc_first_digits="4111",diff --git a/tests/gateway/test_gateway.py b/tests/gateway/test_gateway.pyindex 01d623131f..d1d585cc7d 100644--- a/tests/gateway/test_gateway.py+++ b/tests/gateway/test_gateway.py@@ -3,7 +3,6 @@ from decimal import Decimalimport pytestimport saleor.payment.gateway as gateway-from saleor.core.payments import Gatewayfrom saleor.payment import ChargeStatus, TransactionKindfrom saleor.payment.interface import GatewayResponsefrom saleor.payment.utils import create_payment_information@@ -80,7 +79,7 @@ CONFIRM_RESPONSE = GatewayResponse(raw_response=RAW_RESPONSE,)TOKEN = "token"-USED_GATEWAY = Gateway.DUMMY+USED_GATEWAY = "Dummy"@pytest.fixture@@ -251,7 +250,7 @@ def test_confirm_payment(mock_payment_interface, payment_txn_preauth):def test_list_gateways(mock_payment_interface):- gateways = [Gateway.STRIPE, Gateway.BRAINTREE]+ gateways = ["Stripe", "Braintree"]mock_payment_interface.list_payment_gateways.return_value = gatewayslst = gateway.list_gateways()mock_payment_interface.list_payment_gateways.assert_called_once()diff --git a/tests/test_order.py b/tests/test_order.pyindex 0c0ff5c6c7..a18c9a8f93 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -360,7 +360,7 @@ def test_order_queryset_to_ship(settings):]for order in orders_to_ship:order.payments.create(- gateway=settings.DUMMY,+ gateway="Dummy",charge_status=ChargeStatus.FULLY_CHARGED,total=order.total.gross.amount,captured_amount=order.total.gross.amount,@@ -426,7 +426,7 @@ def test_update_order_prices(order_with_lines):def test_order_payment_flow(- request_checkout_with_item, client, address, customer_user, shipping_zone, settings+ request_checkout_with_item, client, address, customer_user, shipping_zone):request_checkout_with_item.shipping_address = addressrequest_checkout_with_item.billing_address = address.get_copy()@@ -444,21 +444,22 @@ def test_order_payment_flow(user=customer_user,)+ gateway = "Dummy"# Select paymenturl = reverse("order:payment", kwargs={"token": order.token})- data = {"gateway": settings.DUMMY}+ data = {"gateway": gateway}response = client.post(url, data, follow=True)assert len(response.redirect_chain) == 1assert response.status_code == 200redirect_url = reverse(- "order:payment", kwargs={"token": order.token, "gateway": settings.DUMMY}+ "order:payment", kwargs={"token": order.token, "gateway": gateway})assert response.request["PATH_INFO"] == redirect_url# Go to payment details page, enter payment datadata = {- "gateway": settings.DUMMY,+ "gateway": gateway,"is_active": True,"total": order.total.gross.amount,"currency": order.total.gross.currency,diff --git a/tests/test_payment.py b/tests/test_payment.pyindex e5bdfac981..cb2ca85df5 100644--- a/tests/test_payment.py+++ b/tests/test_payment.py@@ -72,7 +72,7 @@ def transaction_data(payment_dummy, gateway_response):@pytest.fixturedef gateway_config():return GatewayConfig(- gateway_name="dummy",+ gateway_name="Dummy",auto_capture=True,template_path="template.html",connection_params={"secret-key": "nobodylikesspanishinqusition"},@@ -188,7 +188,7 @@ def test_handle_fully_paid_order_digital_lines(def test_create_payment(address, settings):data = {- "gateway": settings.DUMMY,+ "gateway": "Dummy","payment_token": "token","total": 10,"currency": settings.DEFAULT_CURRENCY,@@ -197,7 +197,7 @@ def test_create_payment(address, settings):"customer_ip_address": "127.0.0.1",}payment = create_payment(**data)- assert payment.gateway == settings.DUMMY+ assert payment.gateway == "Dummy"same_payment = create_payment(**data)assert payment == same_payment