diff --git a/commerce_coordinator/apps/commercetools/clients.py b/commerce_coordinator/apps/commercetools/clients.py index 65d37fad..1090ff0d 100644 --- a/commerce_coordinator/apps/commercetools/clients.py +++ b/commerce_coordinator/apps/commercetools/clients.py @@ -6,23 +6,15 @@ import decimal import logging from types import SimpleNamespace -from typing import Generic, List, Optional, Tuple, TypeVar, TypedDict, Union +from typing import Generic, List, Optional, Tuple, TypedDict, TypeVar, Union import requests from commercetools import Client as CTClient from commercetools import CommercetoolsError from commercetools.platform.models import Customer as CTCustomer -from commercetools.platform.models import ( - CustomerChangeEmailAction, - CustomerSetCustomFieldAction, -) -from commercetools.platform.models import ( - CustomerSetCustomTypeAction as CTCustomerSetCustomTypeAction, -) -from commercetools.platform.models import ( - CustomerSetFirstNameAction, - CustomerSetLastNameAction, -) +from commercetools.platform.models import CustomerChangeEmailAction, CustomerSetCustomFieldAction +from commercetools.platform.models import CustomerSetCustomTypeAction as CTCustomerSetCustomTypeAction +from commercetools.platform.models import CustomerSetFirstNameAction, CustomerSetLastNameAction from commercetools.platform.models import FieldContainer as CTFieldContainer from commercetools.platform.models import Money as CTMoney from commercetools.platform.models import Order as CTOrder @@ -30,13 +22,10 @@ OrderAddReturnInfoAction, OrderSetReturnItemCustomTypeAction, OrderSetReturnPaymentStateAction, - OrderTransitionLineItemStateAction, + OrderTransitionLineItemStateAction ) from commercetools.platform.models import Payment as CTPayment -from commercetools.platform.models import ( - PaymentAddTransactionAction, - PaymentSetTransactionCustomTypeAction, -) +from commercetools.platform.models import PaymentAddTransactionAction, PaymentSetTransactionCustomTypeAction from commercetools.platform.models import ProductVariant as CTProductVariant from commercetools.platform.models import ( ReturnItemDraft, @@ -44,36 +33,29 @@ ReturnShipmentState, StateResourceIdentifier, TransactionDraft, - TransactionType, + TransactionType ) from commercetools.platform.models import Type as CTType from commercetools.platform.models import TypeDraft as CTTypeDraft -from commercetools.platform.models import ( - TypeResourceIdentifier as CTTypeResourceIdentifier, -) +from commercetools.platform.models import TypeResourceIdentifier as CTTypeResourceIdentifier from commercetools.platform.models.state import State as CTLineItemState from django.conf import settings from openedx_filters.exceptions import OpenEdxFilterException from commerce_coordinator.apps.commercetools.catalog_info.constants import ( DEFAULT_ORDER_EXPANSION, - EdXFieldNames, -) -from commerce_coordinator.apps.commercetools.catalog_info.foundational_types import ( - TwoUCustomTypes, + EDX_PAYPAL_PAYMENT_INTERFACE_NAME, + EDX_STRIPE_PAYMENT_INTERFACE_NAME, + EdXFieldNames ) +from commerce_coordinator.apps.commercetools.catalog_info.foundational_types import TwoUCustomTypes from commerce_coordinator.apps.commercetools.utils import ( find_refund_transaction, handle_commercetools_error, - translate_refund_status_to_transaction_status, + translate_refund_status_to_transaction_status ) from commerce_coordinator.apps.core.constants import ORDER_HISTORY_PER_SYSTEM_REQ_LIMIT -from commerce_coordinator.apps.commercetools.catalog_info.constants import ( - EDX_STRIPE_PAYMENT_INTERFACE_NAME, - EDX_PAYPAL_PAYMENT_INTERFACE_NAME -) - logger = logging.getLogger(__name__) T = TypeVar("T") diff --git a/commerce_coordinator/apps/commercetools/signals.py b/commerce_coordinator/apps/commercetools/signals.py index 1f2ddf8f..b568226b 100644 --- a/commerce_coordinator/apps/commercetools/signals.py +++ b/commerce_coordinator/apps/commercetools/signals.py @@ -6,14 +6,11 @@ from commerce_coordinator.apps.commercetools.catalog_info.constants import TwoUKeys from commerce_coordinator.apps.commercetools.tasks import ( - refund_from_stripe_task, refund_from_paypal_task, - update_line_item_state_on_fulfillment_completion, -) -from commerce_coordinator.apps.core.signal_helpers import ( - CoordinatorSignal, - log_receiver, + refund_from_stripe_task, + update_line_item_state_on_fulfillment_completion ) +from commerce_coordinator.apps.core.signal_helpers import CoordinatorSignal, log_receiver logger = logging.getLogger(__name__) diff --git a/commerce_coordinator/apps/commercetools/tasks.py b/commerce_coordinator/apps/commercetools/tasks.py index 50ec5a63..f775c76f 100644 --- a/commerce_coordinator/apps/commercetools/tasks.py +++ b/commerce_coordinator/apps/commercetools/tasks.py @@ -10,10 +10,10 @@ from django.conf import settings from commerce_coordinator.apps.commercetools.catalog_info.constants import EDX_PAYPAL_PAYMENT_INTERFACE_NAME + from .clients import CommercetoolsAPIClient from .utils import has_full_refund_transaction - logger = logging.getLogger(__name__) stripe.api_key = settings.PAYMENT_PROCESSOR_CONFIG['edx']['stripe']['secret_key'] diff --git a/commerce_coordinator/apps/paypal/views.py b/commerce_coordinator/apps/paypal/views.py index 5286cfab..fc0c0a30 100644 --- a/commerce_coordinator/apps/paypal/views.py +++ b/commerce_coordinator/apps/paypal/views.py @@ -4,26 +4,25 @@ import base64 import logging -from urllib.parse import urlparse import zlib +from urllib.parse import urlparse import requests from cryptography import x509 -from rest_framework.permissions import AllowAny from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import padding from django.conf import settings from rest_framework import status +from rest_framework.permissions import AllowAny from rest_framework.response import Response -from commerce_coordinator.apps.core.views import SingleInvocationAPIView -from commerce_coordinator.apps.commercetools.clients import CommercetoolsAPIClient +from commerce_coordinator.apps.commercetools.clients import CommercetoolsAPIClient +from commerce_coordinator.apps.core.views import SingleInvocationAPIView from commerce_coordinator.apps.paypal.signals import payment_refunded_signal from .models import KeyValueCache - logger = logging.getLogger(__name__) diff --git a/commerce_coordinator/urls.py b/commerce_coordinator/urls.py index 6abafd94..9e4fbc79 100644 --- a/commerce_coordinator/urls.py +++ b/commerce_coordinator/urls.py @@ -38,9 +38,9 @@ from commerce_coordinator.apps.frontend_app_ecommerce import urls as unified_orders_urls from commerce_coordinator.apps.frontend_app_payment import urls as frontend_app_payment_urls from commerce_coordinator.apps.lms import urls as lms_urls +from commerce_coordinator.apps.paypal import urls as paypal_urls from commerce_coordinator.apps.stripe import urls as stripe_urls from commerce_coordinator.apps.titan import urls as titan_urls -from commerce_coordinator.apps.paypal import urls as paypal_urls from commerce_coordinator.settings.base import FAVICON_URL admin.autodiscover()