@@ -243,16 +243,14 @@ def create_enterprise_admin_portal_session(self, request, **kwargs):
243
243
try :
244
244
customer_portal_session = stripe .billing_portal .Session .create (
245
245
customer = stripe_customer_id ,
246
- return_url = "https://enterprise-checkout.stage.edx.org /billing-details/success" ,
246
+ return_url = f" { origin_url } /billing-details/success" ,
247
247
)
248
248
except stripe .error .StripeError as e :
249
- # Generic catch-all for other Stripe errors
250
249
logger .exception (
251
250
f"StripeError creating billing portal session for CheckoutIntent { checkout_intent } : { e } " ,
252
251
)
253
252
return Response (customer_portal_session , status = status .HTTP_422_UNPROCESSABLE_ENTITY )
254
- except Exception as e :
255
- # Any other unexpected error
253
+ except Exception as e : # pylint: disable=broad-except
256
254
logger .exception (
257
255
f"General exception creating billing portal session for CheckoutIntent { checkout_intent } : { e } " ,
258
256
)
@@ -264,6 +262,7 @@ def create_enterprise_admin_portal_session(self, request, **kwargs):
264
262
status = status .HTTP_200_OK ,
265
263
content_type = 'application/json' ,
266
264
)
265
+
267
266
@extend_schema (
268
267
tags = [CUSTOMER_BILLING_API_TAG ],
269
268
summary = 'Create a new Customer Portal Session from the enterprise checkout MFE.' ,
@@ -294,29 +293,27 @@ def create_checkout_portal_session(self, request, pk=None):
294
293
return Response (customer_portal_session , status = status .HTTP_404_NOT_FOUND )
295
294
296
295
if not checkout_intent :
297
- logger .error (f"No checkout intent for id { checkout_intent_id } " )
296
+ logger .error (f"No checkout intent for id { pk } " )
298
297
return Response (customer_portal_session , status = status .HTTP_404_NOT_FOUND )
299
298
300
299
stripe_customer_id = checkout_intent .stripe_customer_id
301
300
enterprise_slug = checkout_intent .enterprise_slug
302
301
303
302
if not (stripe_customer_id or enterprise_slug ):
304
- logger .error (f"No stripe customer id or enterprise slug associated to checkout_intent_id:{ checkout_intent_id } " )
303
+ logger .error (f"No stripe customer id or enterprise slug associated to checkout_intent_id:{ pk } " )
305
304
return Response (customer_portal_session , status = status .HTTP_404_NOT_FOUND )
306
305
307
306
try :
308
307
customer_portal_session = stripe .billing_portal .Session .create (
309
308
customer = stripe_customer_id ,
310
- return_url = "https://enterprise-checkout.stage.edx.org /billing-details/success" ,
309
+ return_url = f" { origin_url } /billing-details/success" ,
311
310
)
312
311
except stripe .error .StripeError as e :
313
- # Generic catch-all for other Stripe errors
314
312
logger .exception (
315
313
f"StripeError creating billing portal session for CheckoutIntent { checkout_intent } : { e } " ,
316
314
)
317
315
return Response (customer_portal_session , status = status .HTTP_422_UNPROCESSABLE_ENTITY )
318
- except Exception as e :
319
- # Any other unexpected error
316
+ except Exception as e : # pylint: disable=broad-except
320
317
logger .exception (
321
318
f"General exception creating billing portal session for CheckoutIntent { checkout_intent } : { e } " ,
322
319
)
0 commit comments