Integrate Lago with Stripe
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import logging
|
||||
|
||||
import stripe
|
||||
from asgiref.sync import sync_to_async
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import redirect, render
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.views import View
|
||||
@@ -14,7 +12,7 @@ from core.forms import NewUserForm
|
||||
|
||||
# from core.lib.products import assemble_plan_map
|
||||
# from core.models import Plan, Session
|
||||
from core.lib import billing
|
||||
# from core.lib import billing
|
||||
from core.lib.notify import raw_sendmsg
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -29,16 +27,13 @@ class Home(LoginRequiredMixin, View):
|
||||
return render(request, self.template_name)
|
||||
|
||||
|
||||
# class Billing(LoginRequiredMixin, View):
|
||||
# template_name = "billing.html"
|
||||
class Billing(LoginRequiredMixin, View):
|
||||
template_name = "billing.html"
|
||||
|
||||
# async def get(self, request):
|
||||
# if not settings.STRIPE_ENABLED:
|
||||
# return redirect(reverse("home"))
|
||||
# plans = await sync_to_async(list)(Plan.objects.all())
|
||||
# user_plans = await sync_to_async(list)(request.user.plans.all())
|
||||
# context = {"plans": plans, "user_plans": user_plans}
|
||||
# return render(request, self.template_name, context)
|
||||
def get(self, request):
|
||||
if not settings.BILLING_ENABLED:
|
||||
return redirect(reverse("home"))
|
||||
return render(request, self.template_name)
|
||||
|
||||
|
||||
# class Order(LoginRequiredMixin, View):
|
||||
@@ -110,12 +105,13 @@ class Signup(CreateView):
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
# class Portal(LoginRequiredMixin, View):
|
||||
# async def get(self, request):
|
||||
# if not settings.STRIPE_ENABLED:
|
||||
# return redirect(reverse("home"))
|
||||
# session = stripe.billing_portal.Session.create(
|
||||
# customer=request.user.stripe_id,
|
||||
# return_url=request.build_absolute_uri(reverse("billing")),
|
||||
# )
|
||||
# return redirect(session.url)
|
||||
class Portal(LoginRequiredMixin, View):
|
||||
def get(self, request):
|
||||
if not settings.BILLING_ENABLED:
|
||||
return redirect(reverse("home"))
|
||||
|
||||
session = stripe.billing_portal.Session.create(
|
||||
customer=request.user.stripe_id,
|
||||
return_url=request.build_absolute_uri(reverse("billing")),
|
||||
)
|
||||
return redirect(session.url)
|
||||
|
||||
Reference in New Issue
Block a user