Skip to content

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

Clean up code

Maciej Korycinski0c9ef188e6ed
diff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.py
index ce660a2d7b..65ce6f53c8 100644
--- a/saleor/payment/gateways/braintree/__init__.py
+++ b/saleor/payment/gateways/braintree/__init__.py
@@ -5,6 +5,7 @@ import braintree as braintree_sdk
from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import pgettext_lazy
+from ... import TransactionKind
from ...interface import ConfigData, GatewayResponse, PaymentData
from .errors import DEFAULT_ERROR_MESSAGE, BraintreeException
from .forms import BraintreePaymentForm
@@ -31,14 +32,6 @@ ERROR_CODES_WHITELIST = {
}
-class TransactionKind:
- AUTH = "auth"
- CAPTURE = "capture"
- CHARGE = "charge"
- REFUND = "refund"
- VOID = "void"
-
-
def get_customer_data(payment_information: PaymentData) -> Dict:
billing = payment_information.billing
return {
diff --git a/saleor/payment/gateways/dummy/__init__.py b/saleor/payment/gateways/dummy/__init__.py
index eec2279f2c..40e154e477 100644
--- a/saleor/payment/gateways/dummy/__init__.py
+++ b/saleor/payment/gateways/dummy/__init__.py
@@ -98,6 +98,9 @@ def process_payment(
if charge_status == ChargeStatus.NOT_CHARGED:
return authorize_response
+ if not config.auto_capture:
+ return authorize_response
+
capture_response = capture(payment_information, config)
if charge_status == ChargeStatus.FULLY_REFUNDED:
return refund(payment_information, config)
diff --git a/saleor/payment/gateways/stripe/__init__.py b/saleor/payment/gateways/stripe/__init__.py
index c842aaa110..a06f37eb7b 100644
--- a/saleor/payment/gateways/stripe/__init__.py
+++ b/saleor/payment/gateways/stripe/__init__.py
@@ -121,7 +121,7 @@ def process_payment(
payment_information: PaymentData, config: ConfigData
) -> GatewayResponse:
# Stripe supports capture during authorize process. No need to run other steps.
- # If 'auto_capture is True', it will also capture funds from the card.
+ # If 'config.auto_capture is True', it will also capture funds from the card.
return authorize(payment_information, config)
diff --git a/tests/gateway/test_stripe.py b/tests/gateway/test_stripe.py
index 0879b66fbf..ad0d1227a4 100644
--- a/tests/gateway/test_stripe.py
+++ b/tests/gateway/test_stripe.py
@@ -24,10 +24,6 @@ from saleor.payment.gateways.stripe import (
refund,
void,
)
-from saleor.payment.gateways.stripe.errors import (
- ORDER_NOT_AUTHORIZED,
- ORDER_NOT_CHARGED,
-)
from saleor.payment.gateways.stripe.forms import (
StripeCheckoutWidget,
StripePaymentModalForm,