Skip to content

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

Fix circular import

Jakub Draganek1a3565fbf926
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index f507815001..c20100c702 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -15,7 +15,7 @@ from ..discount.models import NotApplicable
from ..extensions.manager import get_extensions_manager
from ..order import FulfillmentStatus, OrderStatus, emails
from ..order.models import Fulfillment, FulfillmentLine, Order, OrderLine
-from ..payment import ChargeStatus, gateway
+from ..payment import ChargeStatus
from ..product.utils import (
allocate_stock,
deallocate_stock,
@@ -209,6 +209,7 @@ def cancel_order(user, order, restock):
charge_status=ChargeStatus.FULLY_REFUNDED
)
+ from ..payment import gateway
for payment in payments:
if payment.can_refund():
gateway.refund(payment)
diff --git a/saleor/payment/gateway.py b/saleor/payment/gateway.py
index b042716d71..386b7b0744 100644
--- a/saleor/payment/gateway.py
+++ b/saleor/payment/gateway.py
@@ -8,7 +8,7 @@ from ..extensions.manager import get_extensions_manager
from . import GatewayError, PaymentError, TransactionKind
from .models import Payment, Transaction
from .utils import (
- _gateway_postprocess,
+ gateway_postprocess,
clean_authorize,
clean_capture,
create_payment_information,
@@ -35,7 +35,7 @@ def raise_payment_error(fn):
def payment_postprocess(fn):
def wrapped(*args, **kwargs):
txn = fn(*args, **kwargs)
- _gateway_postprocess(txn, txn.payment)
+ gateway_postprocess(txn, txn.payment)
return txn
return wrapped
diff --git a/saleor/payment/utils.py b/saleor/payment/utils.py
index 080f6f1cd8..7e86a52011 100644
--- a/saleor/payment/utils.py
+++ b/saleor/payment/utils.py
@@ -373,7 +373,7 @@ def validate_gateway_response(response: GatewayResponse):
@transaction.atomic
-def _gateway_postprocess(transaction, payment):
+def gateway_postprocess(transaction, payment):
if not transaction.is_success:
return
@@ -421,7 +421,7 @@ def gateway_process_payment(
**extras,
)
- _gateway_postprocess(transaction, payment)
+ gateway_postprocess(transaction, payment)
return transaction
@@ -452,7 +452,7 @@ def gateway_confirm(payment) -> Transaction:
payment=payment,
payment_token=payment_token,
)
- _gateway_postprocess(transaction, payment)
+ gateway_postprocess(transaction, payment)
return transaction
@@ -488,7 +488,7 @@ def gateway_refund(payment, amount: Decimal = None) -> Transaction:
amount=amount,
)
- _gateway_postprocess(transaction, payment)
+ gateway_postprocess(transaction, payment)
return transaction