Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions enterprise_access/apps/api/v1/tests/test_customer_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_create_enterprise_admin_portal_session_no_stripe_customer(self):
url = reverse('api:v1:customer-billing-create-enterprise-admin-portal-session')

with mock.patch('stripe.billing_portal.Session.create') as mock_create:
mock_create.side_effect = stripe.error.InvalidRequestError(
mock_create.side_effect = stripe.InvalidRequestError(
'Customer does not exist',
'customer'
)
Expand All @@ -161,7 +161,7 @@ def test_create_enterprise_admin_portal_session_stripe_error(self):
url = reverse('api:v1:customer-billing-create-enterprise-admin-portal-session')

with mock.patch('stripe.billing_portal.Session.create') as mock_create:
mock_create.side_effect = stripe.error.InvalidRequestError(
mock_create.side_effect = stripe.InvalidRequestError(
'Customer does not exist',
'customer'
)
Expand Down Expand Up @@ -313,7 +313,7 @@ def test_create_checkout_portal_session_stripe_error(self):
kwargs={'pk': self.checkout_intent.id})

with mock.patch('stripe.billing_portal.Session.create') as mock_create:
mock_create.side_effect = stripe.error.AuthenticationError('Invalid API key')
mock_create.side_effect = stripe.AuthenticationError('Invalid API key')

response = self.client.get(
url,
Expand Down
4 changes: 2 additions & 2 deletions enterprise_access/apps/api/v1/views/customer_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def create_enterprise_admin_portal_session(self, request, **kwargs):
customer=stripe_customer_id,
return_url=f"{origin_url}/{enterprise_slug}",
)
except stripe.error.StripeError as e:
except stripe.StripeError as e:
# TODO: Long term we should be explicit to different types of Stripe error exceptions available
# https://docs.stripe.com/api/errors/handling, https://docs.stripe.com/error-handling
msg = f"StripeError creating billing portal session for CheckoutIntent {checkout_intent}: {e}"
Expand Down Expand Up @@ -312,7 +312,7 @@ def create_checkout_portal_session(self, request, pk=None):
customer=stripe_customer_id,
return_url=f"{origin_url}/billing-details/success",
)
except stripe.error.StripeError as e:
except stripe.StripeError as e:
# TODO: Long term we should be explicit to different types of Stripe error exceptions available
# https://docs.stripe.com/api/errors/handling, https://docs.stripe.com/error-handling
msg = f"StripeError creating billing portal session for CheckoutIntent {checkout_intent}: {e}"
Expand Down
12 changes: 6 additions & 6 deletions enterprise_access/apps/bffs/checkout/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def enhance_with_stripe_data(self):

try:
session = get_stripe_checkout_session(session_id)
except stripe.error.StripeError:
except stripe.StripeError:
logger.exception("Error retrieving Stripe checkout session: %s", session_id)
return

Expand Down Expand Up @@ -376,7 +376,7 @@ def _get_payment_method(session):

try:
payment_intent = get_stripe_payment_intent(payment_intent_id)
except stripe.error.StripeError:
except stripe.StripeError:
logger.exception("Error retrieving Stripe payment intent: %s", payment_intent_id)
return None

Expand All @@ -387,7 +387,7 @@ def _get_payment_method(session):
payment_method = None
try:
payment_method = get_stripe_payment_method(payment_method_id)
except stripe.error.StripeError:
except stripe.StripeError:
logger.exception("Error retrieving Stripe payment method: %s", payment_method_id)
return payment_method

Expand All @@ -409,7 +409,7 @@ def _get_invoice_record(invoice_id, subscription_id):
try:
subscription = get_stripe_subscription(subscription_id)
invoice_id = subscription.get('latest_invoice')
except stripe.error.StripeError:
except stripe.StripeError:
logger.exception("Error retrieving Stripe subscription: %s", subscription_id)
return None

Expand All @@ -421,7 +421,7 @@ def _get_invoice_record(invoice_id, subscription_id):

try:
return get_stripe_invoice(invoice_id)
except stripe.error.StripeError:
except stripe.StripeError:
logger.exception("Error retrieving Stripe invoice: %s", invoice_id)
return None

Expand Down Expand Up @@ -461,6 +461,6 @@ def _get_customer_info(invoice):
customer = get_stripe_customer(customer_id)
result['customer_name'] = customer.get('name')
result['customer_phone'] = customer.get('phone')
except stripe.error.StripeError:
except stripe.StripeError:
logger.exception("Error retrieving Stripe customer: %s", customer_id)
return result
10 changes: 5 additions & 5 deletions enterprise_access/apps/bffs/tests/test_checkout_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def test_load_and_process_no_session_id(self, mock_get_checkout_intent):
def test_enhance_with_stripe_data_session_error(self, mock_session, mock_get_checkout_intent):
"""Test when there's an error retrieving the Stripe session."""
mock_get_checkout_intent.return_value = self.checkout_intent_data
mock_session.side_effect = stripe.error.StripeError("API Error")
mock_session.side_effect = stripe.StripeError("API Error")

self.handler.load_and_process()

Expand All @@ -692,7 +692,7 @@ def test_enhance_with_stripe_data_payment_intent_error(
"""Test when there's an error retrieving the payment intent."""
mock_get_checkout_intent.return_value = self.checkout_intent_data
mock_session.return_value = self.stripe_session
mock_payment_intent.side_effect = stripe.error.StripeError("API Error")
mock_payment_intent.side_effect = stripe.StripeError("API Error")

self.handler.load_and_process()

Expand All @@ -711,7 +711,7 @@ def test_enhance_with_stripe_data_payment_method_error(
mock_get_checkout_intent.return_value = self.checkout_intent_data
mock_session.return_value = self.stripe_session
mock_payment_intent.return_value = self.stripe_payment_intent
mock_payment_method.side_effect = stripe.error.StripeError("API Error")
mock_payment_method.side_effect = stripe.StripeError("API Error")

self.handler.load_and_process()

Expand All @@ -733,7 +733,7 @@ def test_enhance_with_stripe_data_subscription_error(
mock_session.return_value = {**self.stripe_session, 'invoice': None} # Force subscription path
mock_payment_intent.return_value = self.stripe_payment_intent
mock_payment_method.return_value = self.stripe_payment_method
mock_subscription.side_effect = stripe.error.StripeError("API Error")
mock_subscription.side_effect = stripe.StripeError("API Error")

self.handler.load_and_process()

Expand All @@ -757,7 +757,7 @@ def test_enhance_with_stripe_data_invoice_error(
mock_payment_intent.return_value = self.stripe_payment_intent
mock_payment_method.return_value = self.stripe_payment_method
mock_subscription.return_value = self.stripe_subscription
mock_invoice.side_effect = stripe.error.StripeError("API Error")
mock_invoice.side_effect = stripe.StripeError("API Error")

self.handler.load_and_process()

Expand Down
4 changes: 2 additions & 2 deletions enterprise_access/apps/customer_billing/pricing_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_stripe_price_data(

return serialized_data

except stripe.error.StripeError as exc:
except stripe.StripeError as exc:
logger.error(f'Stripe API error fetching price {price_id}: {exc}')
raise StripePricingError(f'Failed to fetch price {price_id}: {exc}') from exc
except Exception as exc:
Expand Down Expand Up @@ -242,7 +242,7 @@ def get_all_stripe_prices(

return prices_by_lookup_key

except stripe.error.StripeError as exc:
except stripe.StripeError as exc:
logger.error(f'Stripe API error fetching all prices: {exc}')
raise StripePricingError(f'Failed to fetch all prices: {exc}') from exc
except Exception as exc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ddt
from django.test import TestCase, override_settings
from edx_django_utils.cache import TieredCache
from stripe.error import InvalidRequestError
from stripe import InvalidRequestError

from enterprise_access.apps.customer_billing import pricing_api

Expand Down
16 changes: 8 additions & 8 deletions enterprise_access/apps/customer_billing/tests/test_stripe_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ def test_get_stripe_checkout_session_cache_miss(self, mock_set, mock_get, mock_r
def test_get_stripe_checkout_session_api_error(self, mock_retrieve):
"""Test API error handling for checkout session."""
# Setup API error
mock_retrieve.side_effect = stripe.error.StripeError("API Error")
mock_retrieve.side_effect = stripe.StripeError("API Error")

# Call function and verify exception is raised
with self.assertRaises(stripe.error.StripeError):
with self.assertRaises(stripe.StripeError):
get_stripe_checkout_session(self.session_id)


Expand Down Expand Up @@ -215,10 +215,10 @@ def test_get_stripe_payment_intent_cache_miss(self, mock_set, mock_get, mock_ret
def test_get_stripe_payment_intent_api_error(self, mock_retrieve):
"""Test API error handling for payment intent."""
# Setup API error
mock_retrieve.side_effect = stripe.error.StripeError("API Error")
mock_retrieve.side_effect = stripe.StripeError("API Error")

# Call function and verify exception is raised
with self.assertRaises(stripe.error.StripeError):
with self.assertRaises(stripe.StripeError):
get_stripe_payment_intent(self.payment_intent_id)


Expand Down Expand Up @@ -282,10 +282,10 @@ def test_get_stripe_invoice_cache_miss(self, mock_set, mock_get, mock_retrieve):
def test_get_stripe_invoice_api_error(self, mock_retrieve):
"""Test API error handling for invoice."""
# Setup API error
mock_retrieve.side_effect = stripe.error.StripeError("API Error")
mock_retrieve.side_effect = stripe.StripeError("API Error")

# Call function and verify exception is raised
with self.assertRaises(stripe.error.StripeError):
with self.assertRaises(stripe.StripeError):
get_stripe_invoice(self.invoice_id)


Expand Down Expand Up @@ -349,10 +349,10 @@ def test_get_stripe_payment_method_cache_miss(self, mock_set, mock_get, mock_ret
def test_get_stripe_payment_method_api_error(self, mock_retrieve):
"""Test API error handling for payment method."""
# Setup API error
mock_retrieve.side_effect = stripe.error.StripeError("API Error")
mock_retrieve.side_effect = stripe.StripeError("API Error")

# Call function and verify exception is raised
with self.assertRaises(stripe.error.StripeError):
with self.assertRaises(stripe.StripeError):
get_stripe_payment_method(self.payment_method_id)


Expand Down
16 changes: 8 additions & 8 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ amqp==5.3.1
# via kombu
analytics-python==1.4.post1
# via -r requirements/base.in
asgiref==3.9.2
asgiref==3.10.0
# via
# django
# django-cors-headers
Expand All @@ -32,7 +32,7 @@ celery==5.5.3
# -r requirements/base.in
# django-celery-results
# edx-celeryutils
certifi==2025.8.3
certifi==2025.10.5
# via requests
cffi==2.0.0
# via
Expand Down Expand Up @@ -68,15 +68,15 @@ coreschema==0.0.4
# via coreapi
crispy-bootstrap5==2025.6
# via -r requirements/base.in
cryptography==46.0.1
cryptography==46.0.2
# via
# pyjwt
# social-auth-core
defusedxml==0.7.1
# via
# python3-openid
# social-auth-core
django==4.2.24
django==4.2.25
# via
# -c requirements/common_constraints.txt
# -r requirements/base.in
Expand Down Expand Up @@ -170,7 +170,7 @@ drf-yasg==1.21.11
# via edx-api-doc-tools
edx-api-doc-tools==2.1.0
# via -r requirements/base.in
edx-auth-backends==4.6.0
edx-auth-backends==4.6.1
# via -r requirements/base.in
edx-braze-client==0.2.5
# via
Expand All @@ -182,7 +182,7 @@ edx-celeryutils==1.4.0
# via -r requirements/base.in
edx-django-release-util==1.5.0
# via -r requirements/base.in
edx-django-utils==8.0.0
edx-django-utils==8.0.1
# via
# -r requirements/base.in
# edx-auth-backends
Expand Down Expand Up @@ -280,7 +280,7 @@ pyjwt[crypto]==2.10.1
# social-auth-core
pymemcache==4.0.0
# via -r requirements/base.in
pymongo==4.15.1
pymongo==4.15.2
# via edx-opaque-keys
pynacl==1.6.0
# via edx-django-utils
Expand Down Expand Up @@ -351,7 +351,7 @@ stevedore==5.5.0
# code-annotations
# edx-django-utils
# edx-opaque-keys
stripe==12.5.1
stripe==13.0.1
# via -r requirements/base.in
text-unidecode==1.3
# via python-slugify
Expand Down
4 changes: 0 additions & 4 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ Django<5.0
# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html
# See https://github.com/openedx/edx-platform/issues/35126 for more info
elasticsearch<7.14.0

# Cause: https://github.com/openedx/edx-lint/issues/458
# This can be unpinned once https://github.com/openedx/edx-lint/issues/459 has been resolved.
pip<24.3
Loading