Возможно ли перенаправление на страницу оформления заказа stripe без AJAX в Django?
У меня есть FormView, где я делаю некоторые действия после отправки формы, а затем я хочу перенаправить на кассу stripe. Возможно ли это без Javascript?
class ApplicationForm(forms.ModelForm):
class Meta:
model = Application
fields = "email", "name"
def save(self, commit=True):
application = super().save(commit=commit)
checkout_session = stripe.checkout.Session.create(...) # I'm creating the session here and do some other stuff with the form input
return application
class ApplicationView(CreateView):
template_name = "application.html"
form_class = ApplicationForm
def get_success_url(self):
# TODO: How do I redirect to Stripe checkout here?
Для этого можно использовать редирект :
from django.shortcuts import redirect
def get_success_url(self):
# Redirect the user to the Stripe Checkout page (i suppose that is an external url from your app)
stripe_checkout_url = 'https://stripe/checkout/url'
return redirect(stripe_checkout_url)
# If it's an app url like: stripe:checkout (name 'checkout' and namespace = 'stripe')
# return redirect('stripe:checkout')