Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe Error: A canceled subscription can only update its cancellation_details #283

Open
jabelone opened this issue Oct 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jabelone
Copy link
Member

jabelone commented Oct 2, 2024

Describe the bug
When a member was trying to "cancel" their old inactive subscription Stripe was returning the error "A canceled subscription can only update its cancellation_details". I suspect there was a glitch with removing the subscription from their profile as they still have an "active" subscription in MM so MM is trying to "cancel" it again. We should add a check for this and gracefully handle it.

The stack trace is below.

Screenshot 2024-10-02 at 12 54 29 pm
2024-10-02T02:47:58.443736379Z 2024-10-02 12:47:58,440 django.request log.py:224 ERROR Internal Server Error: /api/billing/myplan/cancel/ 2024-10-02T02:47:58.443739154Z Traceback (most recent call last): 2024-10-02T02:47:58.443741719Z File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler 2024-10-02T02:47:58.443744571Z raise exc_info[1] 2024-10-02T02:47:58.443747144Z File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 38, in inner 2024-10-02T02:47:58.443749973Z response = await get_response(request) 2024-10-02T02:47:58.443752592Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443755179Z File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler 2024-10-02T02:47:58.443757973Z raise exc_info[1] 2024-10-02T02:47:58.443760540Z File "/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py", line 233, in _get_response_async 2024-10-02T02:47:58.443763314Z response = await wrapped_callback(request, *callback_args, **callback_kwargs) 2024-10-02T02:47:58.443778134Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443781153Z File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 468, in __call__ 2024-10-02T02:47:58.443783963Z ret = await asyncio.shield(exec_coro) 2024-10-02T02:47:58.443786616Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443789283Z File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run 2024-10-02T02:47:58.443792053Z result = self.fn(*self.args, **self.kwargs) 2024-10-02T02:47:58.443794758Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443797809Z File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 522, in thread_handler 2024-10-02T02:47:58.443805022Z return func(*args, **kwargs) 2024-10-02T02:47:58.443807848Z ^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443810510Z File "/usr/local/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view 2024-10-02T02:47:58.443813312Z return view_func(*args, **kwargs) 2024-10-02T02:47:58.443815955Z ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443818586Z File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 70, in view 2024-10-02T02:47:58.443821381Z return self.dispatch(request, *args, **kwargs) 2024-10-02T02:47:58.443824149Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443826898Z File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 509, in dispatch 2024-10-02T02:47:58.443829692Z response = self.handle_exception(exc) 2024-10-02T02:47:58.443832296Z ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443834968Z File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 469, in handle_exception 2024-10-02T02:47:58.443837764Z self.raise_uncaught_exception(exc) 2024-10-02T02:47:58.443840444Z File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception 2024-10-02T02:47:58.443843260Z raise exc 2024-10-02T02:47:58.443845918Z File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 506, in dispatch 2024-10-02T02:47:58.443848746Z response = handler(request, *args, **kwargs) 2024-10-02T02:47:58.443851370Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443854034Z File "/usr/src/app/memberportal/api_billing/views.py", line 626, in post 2024-10-02T02:47:58.443856788Z modified_subscription = stripe.Subscription.modify( 2024-10-02T02:47:58.443859479Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443862138Z File "/usr/local/lib/python3.12/site-packages/stripe/_subscription.py", line 2579, in modify 2024-10-02T02:47:58.443868224Z cls._static_request( 2024-10-02T02:47:58.443871019Z File "/usr/local/lib/python3.12/site-packages/stripe/_api_resource.py", line 177, in _static_request 2024-10-02T02:47:58.443873782Z return _APIRequestor._global_instance().request( 2024-10-02T02:47:58.443950198Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443963794Z File "/usr/local/lib/python3.12/site-packages/stripe/_api_requestor.py", line 196, in request 2024-10-02T02:47:58.443969598Z resp = requestor._interpret_response(rbody, rcode, rheaders) 2024-10-02T02:47:58.443974394Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-10-02T02:47:58.443978839Z File "/usr/local/lib/python3.12/site-packages/stripe/_api_requestor.py", line 732, in _interpret_response 2024-10-02T02:47:58.443983216Z self.handle_error_response(rbody, rcode, resp.data, rheaders) 2024-10-02T02:47:58.443987645Z File "/usr/local/lib/python3.12/site-packages/stripe/_api_requestor.py", line 321, in handle_error_response 2024-10-02T02:47:58.443992197Z raise err
@jabelone jabelone added the bug Something isn't working label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant