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

delete subscriptions from db on cancellation #838

Merged
merged 3 commits into from
Jul 28, 2022
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
10 changes: 7 additions & 3 deletions web_api/web_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pydantic
import requests
import sentry_sdk
import stripe
from django.conf import settings
from django.http import (
Expand Down Expand Up @@ -554,6 +555,9 @@ def stripe_webhook_handler(request: HttpRequest) -> HttpResponse:
logger.warning("invalid signature for webhook request", exc_info=True)
raise BadRequest

sentry_sdk.set_tag("stripe_event_type", event.type)
logger.info("stripe_event_type=%s", event.type)

# https://stripe.com/docs/billing/lifecycle#subscription-lifecycle

# triggered when a customer completes the Stripe Checkout form.
Expand Down Expand Up @@ -611,9 +615,9 @@ def stripe_webhook_handler(request: HttpRequest) -> HttpResponse:
raise BadRequest
stripe_customer.update_from_stripe()
elif event.type == "customer.subscription.deleted":
# I don't think we need to do anything on subscription deletion. We can
# let the subscription time run out.
pass
StripeCustomerInformation.objects.filter(
customer_id=event.data.object.customer
).delete()
elif event.type == "invoice.payment_action_required":
logger.warning("more action required for payment %s", event)
elif event.type == "invoice.payment_failed":
Expand Down
2 changes: 1 addition & 1 deletion web_ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"jest-watch-typeahead": "0.4.2",
"lodash": "^4.17.15",
"mini-css-extract-plugin": "0.8.0",
"node-sass": "^4.13.1",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.5.0",
"postcss-flexbugs-fixes": "4.1.0",
Expand All @@ -83,6 +82,7 @@
"react-router-dom": "^5.1.2",
"resolve": "1.12.2",
"resolve-url-loader": "3.1.1",
"sass": "^1.54.0",
"sass-loader": "8.0.0",
"semver": "6.3.0",
"style-loader": "1.0.0",
Expand Down
Loading