Skip to content

Commit 69c0ee9

Browse files
authored
Add a basic djstripe integration (#9087)
* Add a basic djstripe integration This will allow us to run migrations, and configure it initially in production.
1 parent f724549 commit 69c0ee9

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

readthedocs/settings/base.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def INSTALLED_APPS(self): # noqa
175175
'django_filters',
176176
'polymorphic',
177177
'simple_history',
178+
'djstripe',
178179

179180
# our apps
180181
'readthedocs.projects',
@@ -741,9 +742,24 @@ def DOCKER_LIMITS(self):
741742
TAGGIT_TAGS_FROM_STRING = 'readthedocs.projects.tag_utils.rtd_parse_tags'
742743

743744
# Stripe
745+
# Existing values we use
744746
STRIPE_SECRET = None
745747
STRIPE_PUBLISHABLE = None
746748

749+
# DJStripe values -- **CHANGE THESE IN PRODUCTION**
750+
STRIPE_LIVE_SECRET_KEY = None
751+
STRIPE_TEST_SECRET_KEY = "sk_test_x" # A default so the `checks` don't fail
752+
DJSTRIPE_WEBHOOK_SECRET = None
753+
STRIPE_LIVE_MODE = False # Change to True in production
754+
# This is less optimal than setting the webhook secret
755+
# However, the app won't start without the secret
756+
# with this setting set to the default
757+
DJSTRIPE_WEBHOOK_VALIDATION = "retrieve_event"
758+
759+
# These values shouldn't need to change..
760+
DJSTRIPE_FOREIGN_KEY_TO_FIELD = "id"
761+
DJSTRIPE_USE_NATIVE_JSONFIELD = True # We recommend setting to True for new installations
762+
747763
# Do Not Track support
748764
DO_NOT_TRACK_ENABLED = False
749765

readthedocs/urls.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
from django.contrib import admin
1010
from django.views.generic.base import RedirectView, TemplateView
1111

12-
from readthedocs.core.views import HomepageView, SupportView, do_not_track, server_error_500
12+
from readthedocs.core.views import (
13+
HomepageView,
14+
SupportView,
15+
do_not_track,
16+
server_error_500,
17+
)
1318
from readthedocs.search.api import PageSearchAPIView
1419
from readthedocs.search.views import GlobalSearchView
1520

@@ -51,6 +56,8 @@
5156
re_path(r'^builds/', include('readthedocs.builds.urls')),
5257
# For testing the 500's with DEBUG on.
5358
re_path(r'^500/$', handler500),
59+
# Put this as a unique path for the webhook, so we don't clobber existing Stripe URL's
60+
re_path(r"^djstripe/", include("djstripe.urls", namespace="djstripe")),
5461
]
5562

5663
project_urls = [
@@ -156,6 +163,7 @@
156163

157164
if settings.ALLOW_ADMIN:
158165
groups.append(admin_urls)
166+
159167
if settings.DEBUG:
160168
import debug_toolbar
161169

requirements/pip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ django-gravatar2==1.4.4
7070
pytz==2022.1
7171
django-kombu==0.9.4
7272
stripe==2.72.0
73+
dj-stripe==2.6.1
7374
regex==2022.3.15
7475
markdown==3.3.6
7576

0 commit comments

Comments
 (0)