Skip to content

Commit 39655a6

Browse files
committed
feat: create checkout portal session
1 parent 8b303e8 commit 39655a6

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

enterprise_access/apps/api/v1/views/customer_billing.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,45 +179,45 @@ def create_checkout_session(self, request, *args, **kwargs):
179179

180180
@extend_schema(
181181
tags=[CUSTOMER_BILLING_API_TAG],
182-
summary='Create a new Customer Portal Session.',
182+
summary='Create a new Customer Portal Session from the CheckoutMFE.',
183183
)
184184
@action(
185185
detail=True,
186186
methods=['get'],
187-
url_path='create-portal-session',
187+
url_path='create-checkout-portal-session',
188188
)
189189
# TODO: determine permission on this API, must be authenticated at the very least
190190
# # UUID in path is used as the "permission object" for role-based auth.
191191
# @permission_required(
192192
# CUSTOMER_BILLING_CREATE_PORTAL_SESSION_PERMISSION,
193193
# fn=lambda request, pk: pk
194194
# )
195-
def create_portal_session(self, request, **kwargs):
195+
def create_checkout_portal_session(self, request, **kwargs):
196196
"""
197197
Create a new Customer Portal Session. Response dict contains "url" key
198198
that should be attached to a button that the customer clicks.
199199
200200
Response structure defined here: https://docs.stripe.com/api/customer_portal/sessions/create
201201
"""
202202
customer_portal_session = None
203-
checkout_intent_id = str(kwargs['pk'])
204-
checkout_intent = CheckoutIntent.objects.get(id=checkout_intent_id)
203+
stripe_customer_id = str(kwargs['pk'])
204+
# checkout_intent = CheckoutIntent.objects.get(id=checkout_intent_id)
205205

206-
if not checkout_intent:
207-
logger.error(f"No checkout intent for id {checkout_intent_id}")
208-
return Response(customer_portal_session, status=status.HTTP_404_NOT_FOUND)
206+
# if not checkout_intent:
207+
# logger.error(f"No checkout intent for id {checkout_intent_id}")
208+
# return Response(customer_portal_session, status=status.HTTP_404_NOT_FOUND)
209+
#
210+
# stripe_customer_id = checkout_intent.stripe_customer_id
211+
# enterprise_slug = checkout_intent.enterprise_slug
209212

210-
stripe_customer_id = checkout_intent.stripe_customer_id
211-
enterprise_slug = checkout_intent.enterprise_slug
212-
213-
if not (stripe_customer_id or enterprise_slug):
214-
logger.error(f"No stripe customer id or enterprise slug associated to checkout_intent_id:{checkout_intent_id}")
215-
return Response(customer_portal_session, status=status.HTTP_404_NOT_FOUND)
213+
# if not (stripe_customer_id or enterprise_slug):
214+
# logger.error(f"No stripe customer id or enterprise slug associated to checkout_intent_id:{checkout_intent_id}")
215+
# return Response(customer_portal_session, status=status.HTTP_404_NOT_FOUND)
216216

217217
try:
218218
customer_portal_session = stripe.billing_portal.Session.create(
219219
customer=stripe_customer_id,
220-
return_url=f"https://portal.edx.org/{enterprise_slug}",
220+
return_url=f"https://google.com",
221221
)
222222
except stripe.error.StripeError as e:
223223
# Generic catch-all for other Stripe errors

0 commit comments

Comments
 (0)