def METHOD_NAME(self, form):
    """
    Redirect to Stripe Checkout for users to buy a subscription.
    Users can buy a new subscription if the current one
    has been deleted after they canceled it.
    """
    stripe_subscription = self.get_object()
    if (
        not stripe_subscription
        or stripe_subscription.status != SubscriptionStatus.canceled
    ):
        raise Http404()
    stripe_price = get_object_or_404(djstripe.Price, id=form.cleaned_data["plan"])
    url = self.request.build_absolute_uri(self.get_success_url())
    organization = self.get_organization()
    # pylint: disable=broad-except
    try:
        stripe_customer = get_or_create_stripe_customer(organization)
        checkout_session = stripe.checkout.Session.create(
            customer=stripe_customer.id,
            payment_method_types=['card'],
            line_items=[
                {
                    "price": stripe_price.id,
                    "quantity": 1,
                }
            ],
            mode='subscription',
            success_url=url + '?upgraded=true',
            cancel_url=url,
        )
        return HttpResponseRedirect(checkout_session.url)
    except Exception:
        log.exception(
            'Error while creating a Stripe checkout session.',
            organization_slug=organization.slug,
            price=stripe_price.id,
        )
        messages.error(
            self.request,
            _('There was an error connecting to Stripe, please try again in a few minutes.'),
        )
        return HttpResponseRedirect(self.get_success_url())