Skip to content

Commit

Permalink
fix: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aht007 committed Dec 13, 2024
1 parent 6f5fc2a commit 8f8a4a8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 44 deletions.
44 changes: 13 additions & 31 deletions commerce_coordinator/apps/commercetools/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,74 +6,56 @@
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
from commercetools.platform.models import (
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,
ReturnPaymentState,
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")
Expand Down
9 changes: 3 additions & 6 deletions commerce_coordinator/apps/commercetools/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
2 changes: 1 addition & 1 deletion commerce_coordinator/apps/commercetools/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
9 changes: 4 additions & 5 deletions commerce_coordinator/apps/paypal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down
2 changes: 1 addition & 1 deletion commerce_coordinator/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8f8a4a8

Please sign in to comment.