Пример #1
0
    def get(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=args[0])
        product = get_product(generate_product_title(application))
        user = application.applicant.id

        error_url = request.build_absolute_uri(
            reverse('wl_applications:preview'))
        success_url = request.build_absolute_uri(
            reverse('wl_applications:complete'))

        parameters = {
            'system': PAYMENT_SYSTEM_ID,
            'basket_owner': user,
            'associateInvoiceWithToken': True,
            'checkoutWithToken': True,
            'fallback_url': error_url,
            'return_url': success_url,
            'forceRedirect': True,
            'template': 'wl/payment_information.html',
            'proxy': is_officer(request.user),
            "products": [{
                "id": product.id if product is not None else None
            }],
            "vouchers": []
        }
        headers = {
            'X-CSRFToken': request.COOKIES.get('csrftoken'),
            'Referer': request.META.get('HTTP_REFERER'),
        }
        headers.update(JSON_REQUEST_HEADER_PARAMS)

        # senior discount
        if application.is_senior_offer_applicable:
            parameters['vouchers'].append({'code': SENIOR_VOUCHER_CODE})

        url = request.build_absolute_uri(
            reverse('payments:ledger-initial-checkout'))

        response = requests.post(url,
                                 headers=headers,
                                 cookies=request.COOKIES,
                                 data=json.dumps(parameters))

        return HttpResponse(response.content)
Пример #2
0
    def get(self, request, *args, **kwargs):
        application = utils.get_session_application(self.request.session)

        # update invoice reference if received, else keep the same
        application.invoice_reference = request.GET.get(
            'invoice', application.invoice_reference)

        application.save()

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_title(application)) and \
            not application.application_type == 'amendment'

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Пример #3
0
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        kwargs['is_payment_required'] = not is_licence_free(generate_product_title(application)) and \
            not application.invoice_reference and is_customer(self.request.user)

        if application.data:
            utils.convert_documents_to_url(application.data, application.documents.all(), '')

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = utils.\
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)
        else:
            kwargs['data'] = application.data

        kwargs['application'] = application

        return super(PreviewView, self).get_context_data(**kwargs)
Пример #4
0
    def get(self, request, *args, **kwargs):
        application = utils.get_session_application(self.request.session)

        application.lodgement_sequence += 1
        application.lodgement_date = datetime.now().date()

        if application.customer_status == 'amendment_required':
            # this is a 're-lodged' application after some amendment were required.
            # from this point we assume that all the amendments have been amended.
            AmendmentRequest.objects.filter(application=application).filter(
                status='requested').update(status='amended')
            application.review_status = 'amended'
            application.processing_status = 'ready_for_action'
        else:
            application.processing_status = 'new'

        application.customer_status = 'under_review'

        if not application.lodgement_number:
            application.lodgement_number = '%s-%s' % (
                str(application.licence_type.pk).zfill(LICENCE_TYPE_NUM_CHARS),
                str(application.pk).zfill(LODGEMENT_NUMBER_NUM_CHARS))

        application.log_user_action(
            ApplicationUserAction.ACTION_LODGE_APPLICATION.format(application),
            request)
        # update invoice reference if received, else keep the same
        application.invoice_reference = request.GET.get(
            'invoice', application.invoice_reference)

        application.save(version_user=application.applicant,
                         version_comment='Details Modified')

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_title(application)) and \
            not application.application_type == 'amendment'

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Пример #5
0
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        kwargs['is_payment_required'] = not is_licence_free(generate_product_title(application)) and \
            not application.invoice_reference and is_customer(self.request.user)

        if application.data:
            utils.convert_documents_to_url(application.data,
                                           application.documents.all(), '')

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = utils.\
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)
        else:
            kwargs['data'] = application.data

        kwargs['application'] = application

        return super(PreviewView, self).get_context_data(**kwargs)
Пример #6
0
    def get(self, request, *args, **kwargs):
        application = utils.get_session_application(self.request.session)

        application.lodgement_sequence += 1
        application.lodgement_date = datetime.now().date()

        if application.customer_status == 'amendment_required':
            # this is a 're-lodged' application after some amendment were required.
            # from this point we assume that all the amendments have been amended.
            AmendmentRequest.objects.filter(application=application).filter(status='requested').update(status='amended')
            application.review_status = 'amended'
            application.processing_status = 'ready_for_action'
        else :
            application.processing_status = 'new'

        application.customer_status = 'under_review'

        if not application.lodgement_number:
            application.lodgement_number = '%s-%s' % (str(application.licence_type.pk).zfill(LICENCE_TYPE_NUM_CHARS),
                                                      str(application.pk).zfill(LODGEMENT_NUMBER_NUM_CHARS))

        application.log_user_action(
            ApplicationUserAction.ACTION_LODGE_APPLICATION.format(application),
            request
        )
        # update invoice reference if received, else keep the same
        application.invoice_reference = request.GET.get('invoice', application.invoice_reference)

        application.save(version_user=application.applicant, version_comment='Details Modified')

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_title(application)) and \
            not application.application_type == 'amendment'

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Пример #7
0
    def get(self, request, *args, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, e.message)
            return redirect('wl_applications:new_application')

        # update invoice reference if received, else keep the same
        application.invoice_reference = request.GET.get('invoice', application.invoice_reference)

        application.save()

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_title(application)) and \
            not application.is_licence_amendment

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Пример #8
0
    def get(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=args[0])
        product = get_product(generate_product_title(application))
        user = application.applicant.id

        error_url = request.build_absolute_uri(
            reverse('wl_applications:preview'))
        success_url = request.build_absolute_uri(
            reverse('wl_applications:complete'))

        basket_params = {
            'products': [{
                'id': product.id if product is not None else None
            }],
            'vouchers': [],
            'system': PAYMENT_SYSTEM_ID
        }
        # senior discount
        if application.is_senior_offer_applicable:
            basket_params['vouchers'].append({'code': SENIOR_VOUCHER_CODE})
        basket, basket_hash = create_basket_session(request, basket_params)

        checkout_params = {
            'system': PAYMENT_SYSTEM_ID,
            'basket_owner': user,
            'associate_invoice_with_token': True,
            'fallback_url': error_url,
            'return_url': success_url,
            'force_redirect': True,
            'template': 'wl/payment_information.html',
            'proxy': is_officer(request.user),
        }
        create_checkout_session(request, checkout_params)

        if checkout_params['proxy']:
            response = place_order_submission(request)
        else:
            response = HttpResponseRedirect(reverse('checkout:index'))
        return response
Пример #9
0
    def get(self, request, *args, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, str(e))
            return redirect('wl_applications:new_application')

        # update invoice reference if received, else keep the same
        application.invoice_reference = request.GET.get(
            'invoice', application.invoice_reference)

        application.save()

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_title(application)) and \
            not application.is_licence_amendment

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Пример #10
0
    def get(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=args[0])
        product = get_product(generate_product_title(application))
        user = application.applicant.id

        error_url = request.build_absolute_uri(reverse('wl_applications:preview'))
        success_url = request.build_absolute_uri(reverse('wl_applications:complete'))

        basket_params = {
            'products': [
                {'id': product.id if product is not None else None}
            ],
            'vouchers': [],
            'system': PAYMENT_SYSTEM_ID
        }
        # senior discount
        if application.is_senior_offer_applicable:
            basket_params['vouchers'].append({'code': SENIOR_VOUCHER_CODE})
        basket, basket_hash = create_basket_session(request, basket_params)

        checkout_params = {
            'system': PAYMENT_SYSTEM_ID,
            'basket_owner': user,
            'associate_invoice_with_token': True,
            'fallback_url': error_url,
            'return_url': success_url,
            'force_redirect': True,
            'template': 'wl/payment_information.html',
            'proxy': is_officer(request.user),
        }
        create_checkout_session(request, checkout_params)

        if checkout_params['proxy']:
            response = place_order_submission(request)
        else:
            response = HttpResponseRedirect(reverse('checkout:index'))
        return response
Пример #11
0
    def get(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=args[0])
        product = get_product(generate_product_title(application))
        user = application.applicant.id

        error_url = request.build_absolute_uri(reverse('wl_applications:preview'))
        success_url = request.build_absolute_uri(reverse('wl_applications:complete'))

        parameters = {
            'system': PAYMENT_SYSTEM_ID,
            'basket_owner': user,
            'associateInvoiceWithToken': True,
            'checkoutWithToken': True,
            'fallback_url': error_url,
            'return_url': success_url,
            'forceRedirect': True,
            'template': 'wl/payment_information.html',
            'proxy': is_officer(request.user),
            "products": [
                {"id": product.id if product is not None else None}
            ],
            "vouchers": []
        }

        # senior discount
        if application.is_senior_offer_applicable:
            parameters['vouchers'].append({'code': SENIOR_VOUCHER_CODE})

        url = request.build_absolute_uri(
            reverse('payments:ledger-initial-checkout')
        )

        response = requests.post(url, headers=JSON_REQUEST_HEADER_PARAMS, cookies=request.COOKIES,
                                 data=json.dumps(parameters))

        return HttpResponse(response.content)