From 193b87bbb5f2286343e48e1fb0a9d462f2f5a5f2 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 3 Oct 2018 09:36:43 +0200 Subject: [PATCH] Use proper payment form --- datacenterlight/views.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 20206d1b..d66eb8c3 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -365,14 +365,23 @@ class PaymentOrderView(FormView): # payment details form before we go on to verify payment if ('generic_payment_type' in request.session and self.request.session['generic_payment_type'] == 'generic'): - generic_payment_form = GenericPaymentForm( - data=request.POST, prefix='generic_payment_form' - ) + if 'product_id' in request.session: + generic_payment_form = ProductPaymentForm( + data=request.POST, prefix='generic_payment_form', + product_id=request.session['product_id'] + ) + else: + generic_payment_form = GenericPaymentForm( + data=request.POST, prefix='generic_payment_form' + ) if generic_payment_form.is_valid(): logger.debug("Generic payment form is valid.") - product = generic_payment_form.cleaned_data.get( - 'product_name' - ) + if 'product_id' in request.session: + product = generic_payment_form.product + else: + product = generic_payment_form.cleaned_data.get( + 'product_name' + ) gp_details = { "product_name": product.product_name, "amount": generic_payment_form.cleaned_data.get(