From a405e9a8e3e084f3fdc13c6e78d75c1c7d8e8184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 8 Dec 2015 00:12:40 +0200 Subject: [PATCH] Do braintree setup once in local_settings, not in every request. --- hc/payments/views.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/hc/payments/views.py b/hc/payments/views.py index f49911b8..49b54a19 100644 --- a/hc/payments/views.py +++ b/hc/payments/views.py @@ -1,5 +1,4 @@ import braintree -from django.conf import settings from django.contrib.auth.decorators import login_required from django.contrib import messages from django.http import JsonResponse @@ -9,16 +8,6 @@ from django.views.decorators.http import require_POST from .models import Subscription -def setup_braintree(): - kw = { - "merchant_id": settings.BRAINTREE_MERCHANT_ID, - "public_key": settings.BRAINTREE_PUBLIC_KEY, - "private_key": settings.BRAINTREE_PRIVATE_KEY - } - - braintree.Configuration.configure(settings.BRAINTREE_ENV, **kw) - - @login_required def get_client_token(request): sub = Subscription.objects.get(user=request.user) @@ -30,8 +19,6 @@ def get_client_token(request): def pricing(request): - setup_braintree() - sub = None if request.user.is_authenticated(): try: @@ -61,7 +48,6 @@ def create_plan(request): price = int(request.POST["price"]) assert price in (2, 5, 10, 15, 20, 25, 50, 100) - setup_braintree() sub = Subscription.objects.get(user=request.user) if not sub.customer_id: result = braintree.Customer.create({}) @@ -101,7 +87,6 @@ def create_plan(request): @login_required @require_POST def update_plan(request): - setup_braintree() sub = Subscription.objects.get(user=request.user) price = int(request.POST["price"]) @@ -119,7 +104,6 @@ def update_plan(request): @login_required @require_POST def cancel_plan(request): - setup_braintree() sub = Subscription.objects.get(user=request.user) braintree.Subscription.cancel(sub.subscription_id)