Allow Stripe configuration via environment variables
This commit is contained in:
parent
96ba5f1906
commit
5990144005
2 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,7 @@ import stripe
|
|||
|
||||
from datetime import timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseNotFound, HttpResponseBadRequest, FileResponse
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.urls import reverse
|
||||
|
@ -222,12 +223,15 @@ def activate_key(request):
|
|||
|
||||
def purchase_key(request):
|
||||
"""Generate a prospective key and redirect to the Stripe payment portal"""
|
||||
|
||||
stripe.api_key = settings.STRIPE_API_KEY
|
||||
|
||||
key = ActivationKey.key_default()
|
||||
redirect_url = request.build_absolute_uri(reverse(activate_key)) + f"?key={key}"
|
||||
stripe_session = stripe.checkout.Session.create(
|
||||
line_items=[
|
||||
{
|
||||
"price": "price_1Mh1I6GLlkkooLVio8W3TGkR",
|
||||
"price": settings.STRIPE_PRICE_ID,
|
||||
"quantity": 1,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -164,4 +164,5 @@ CELERY_TIMEZONE = TIME_ZONE
|
|||
CELERY_BROKER_URL = REDIS_CELERY_URL
|
||||
|
||||
# Stripe payment processing
|
||||
stripe.api_key = os.environ['STRIPE_API_KEY']
|
||||
STRIPE_API_KEY = os.environ['STRIPE_API_KEY']
|
||||
STRIPE_PRICE_ID = os.environ['STRIPE_PRICE_ID']
|
||||
|
|
Loading…
Reference in a new issue