feat: redirect user after successful payments for VM creation
parent
e63719764a
commit
5ec87c83ec
|
@ -117,7 +117,10 @@ class BillingTest(TestCase):
|
|||
## payment success page; no real functionality but user is redirected here
|
||||
# by stripe if payment is successful
|
||||
resp = c.get(reverse("billing.invoice.success", args=(payment.public_ref,)))
|
||||
self.assertEqual(b"success" in resp.content, True)
|
||||
self.assertEqual(
|
||||
resp.headers["Location"],
|
||||
reverse("infra.create", args=(payment.instance_name,)),
|
||||
)
|
||||
|
||||
## payment failure page; no real functionality but user is redirected here
|
||||
# by stripe if payment is successful
|
||||
|
|
|
@ -23,6 +23,7 @@ from django.urls import reverse
|
|||
from payments import get_payment_model, RedirectNeeded, PaymentStatus
|
||||
from dash.models import Instance
|
||||
from django.db.models import Q
|
||||
from infrastructure.utils import create_vm_if_not_exists
|
||||
|
||||
|
||||
def default_ctx(title: str, username: str):
|
||||
|
@ -115,9 +116,7 @@ def payment_success(request, payment_public_id):
|
|||
payment = get_object_or_404(
|
||||
get_payment_model(), public_ref=payment_public_id, paid_by=request.user
|
||||
)
|
||||
return HttpResponse(
|
||||
f"{payment.description} worth {payment.total}{payment.currency} paid via {payment.variant} is success"
|
||||
)
|
||||
return redirect(reverse("infra.create", args=(payment.instance_name,)))
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
|
@ -48,7 +48,7 @@ def create_instance(request, instance_name: str):
|
|||
if not payment_fullfilled(instance=instance):
|
||||
return redirect(reverse("billing.invoice.generate", args=(instance_name,)))
|
||||
|
||||
create_vm_if_not_exists()
|
||||
create_vm_if_not_exists(instance=instance)
|
||||
|
||||
return HttpResponse()
|
||||
|
||||
|
|
Loading…
Reference in New Issue