I've been following this tutorial (https://www.saaspegasus.com/guides/django-stripe-integrate/) on integrating a subscription service to my application. Everything seems fine, when i checkout it updates my stripe database with the new subscription, but i get a NoReverseMatch error after clicking the checkout button. Specifically, the error says "NoReverseMatch at /subscription-confirm/ Reverse for 'subscription_details' not found. 'subscription_details' is not a valid view function or pattern name." Nowhere in my code do i define a "subscription_details", i was assuming that maybe this was something that came included in the djstripe package? Also the tutorial does nothing to define it either. I'm kind of lost here. The one thing that i see is a little odd is on my views file, when trying to import 'from djstripe.settings import djstripe_settings' and 'from djstripe.models import Subscription', that Pylance isnt recognizing djstripe.settings or djstripe.models. Here is some of the code i think is relevant, if you guys want to see more just ask. Thanks in advance!
from typing import Any
from django.db.models.query import QuerySet
from django.urls import reverse_lazy, reverse
from django.views.generic.edit import CreateView
from django.views.generic import TemplateView, ListView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.decorators import login_required
from .models import Picks
from django.shortcuts import render
from django.core.mail import send_mail, BadHeaderError
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib import messages
from django.contrib.auth import get_user_model
import stripe
from djstripe.settings import djstripe_settings
from djstripe.models import Subscription
from .forms import CustomUserCreationForm
@login_required
def subscription_confirm(request):
# set our stripe keys up
stripe.api_key = djstripe_settings.STRIPE_SECRET_KEY
# get the session id from the URL and retrieve the session object from Stripe
session_id = request.GET.get("session_id")
session = stripe.checkout.Session.retrieve(session_id)
# get the subscribing user from the client_reference_id we passed in above
client_reference_id = int(session.client_reference_id)
subscription_holder = get_user_model().objects.get(id=client_reference_id)
# sanity check that the logged in user is the one being updated
assert subscription_holder == request.user
# get the subscription object form Stripe and sync to djstripe
subscription = stripe.Subscription.retrieve(session.subscription)
djstripe_subscription = Subscription.sync_from_stripe_data(subscription)
# set the subscription and customer on our user
subscription_holder.subscription = djstripe_subscription
subscription_holder.customer = djstripe_subscription.customer
subscription_holder.save()
# show a message to the user and redirect
messages.success(request, f"You've successfully signed up. Thanks for the support!")
return HttpResponseRedirect(reverse("subscription_details"))
from django.urls import path
from .views import SignUpView, PicksView, HomeView, ThanksView, subscription_confirm
urlpatterns = [
path('', HomeView.as_view(), name='home'),
path('signup/', SignUpView.as_view(), name='signup'),
path('picks/', PicksView.as_view(), name='picks'),
path('thankyou', ThanksView.as_view(), name='thanks'),
path("subscription-confirm/", subscription_confirm, name="subscription_confirm"),
]