Пример #1
0
def confirmation(request):
    if request.method == 'POST':
        trainee = Trainee.objects.get(code=request.POST["code2"])
        form = ConfirmationForm(request.POST, request.FILES, instance=trainee)
        if form.is_valid():
            form.save()
            trainee.confirmado = True
            trainee.save()
            return HttpResponse("success")
        else:
            context = {
                'forms':[form,], 
                'form_message':"Congratulations for being accepted! Please fill out this additional information so we can get started processing your immigration papers",
                'locale':'en-US',
            }
            return render(request, 'fileManager/form.html', context)

    else:
        form = ConfirmationForm()
        context = {
            'forms':[form,], 
            'form_message':"Congratulations for being accepted! Please fill out this additional information so we can get started processing your immigration papers",
                'locale':'en-US',
            }
        return render(request, 'fileManager/form.html', context)
Пример #2
0
 def _receive_confirmation(self, request, origin):
     query_dict = dict((key.lower(), value) for key, value in request.GET.iteritems())
     query_dict.update({
         'order': query_dict.get('orderid', 0),
         'origin': origin,
     })
     confirmation = ConfirmationForm(query_dict)
     if confirmation.is_valid():
         confirmation.save()
     else:
         raise ValidationError('Confirmation sent by PSP did not validate: %s' % confirmation.errors)
     shaoutsign = self._get_sha_sign(query_dict, self.SHA_OUT_PARAMETERS,
                     settings.VIVEUM_PAYMENT.get('SHA1_OUT_SIGNATURE'))
     if shaoutsign != confirmation.cleaned_data['shasign']:
         raise SuspiciousOperation('Confirm redirection by PSP has a divergent SHA1 signature')
     self.logger.info('PSP redirected client with status %s for order %s',
         confirmation.cleaned_data['status'], confirmation.cleaned_data['orderid'])
     return confirmation
 def _receive_confirmation(self, request, origin):
     query_dict = dict((key.lower(), value) for key, value in request.GET.iteritems())
     query_dict.update({
         'order': query_dict.get('orderid', 0),
         'origin': origin,
     })
     confirmation = ConfirmationForm(query_dict)
     if confirmation.is_valid():
         confirmation.save()
     else:
         raise ValidationError('Confirmation sent by PSP did not validate: %s' % confirmation.errors)
     shaoutsign = self._get_sha_sign(query_dict, self.SHA_OUT_PARAMETERS,
                     settings.VIVEUM_PAYMENT.get('SHA1_OUT_SIGNATURE'))
     if shaoutsign != confirmation.cleaned_data['shasign']:
         raise SuspiciousOperation('Confirm redirection by PSP has a divergent SHA1 signature')
     self.logger.info('PSP redirected client with status %s for order %s',
         confirmation.cleaned_data['status'], confirmation.cleaned_data['orderid'])
     return confirmation
Пример #4
0
 def payment_was_successful(self, request):
     '''
     This listens to a confirmation sent by one of the IPayment servers.
     Valid payments are commited as confirmed payments into their model.
     The intention of this view is not to display any useful information,
     since the HTTP-client is a server located at IPayment.
     '''
     if request.method != 'POST':
         return HttpResponseBadRequest()
     try:
         if settings.IPAYMENT['checkOriginatingIP']:
             self._check_originating_ipaddr(request)
         post = request.POST.copy()
         if 'trx_amount' in post:
             post['trx_amount'] = (Decimal(post['trx_amount']) / Decimal('100')) \
                                                 .quantize(Decimal('0.00'))
         if 'ret_transdate' and 'ret_transtime' in post:
             post['ret_transdatetime'] = datetime.strptime(
                 post['ret_transdate'] + ' ' + post['ret_transtime'],
                 '%d.%m.%y %H:%M:%S')
         confirmation = ConfirmationForm(post)
         if not confirmation.is_valid():
             raise SuspiciousOperation(
                 'Confirmation by IPayment rejected: '
                 'POST data does not contain all expected fields.')
         if not settings.IPAYMENT['useSessionId']:
             self._check_ret_param_hash(request.POST)
         confirmation.save()
         order = self.shop.get_order_for_id(
             confirmation.cleaned_data['shopper_id'])
         self.logger.info('IPayment for %s confirmed %s', order,
                          confirmation.cleaned_data['ret_status'])
         if confirmation.cleaned_data['ret_status'] == 'SUCCESS':
             self.shop.confirm_payment(
                 order, confirmation.cleaned_data['trx_amount'],
                 confirmation.cleaned_data['ret_trx_number'],
                 self.backend_name)
         return HttpResponse('OK')
     except Exception as exception:
         # since this response is sent to IPayment, catch errors locally
         logging.error('POST data: ' + request.POST.__str__())
         logging.error(exception.__str__())
         traceback.print_exc()
         return HttpResponseServerError('Internal error in ' + __name__)
Пример #5
0
 def payment_was_successful(self, request):
     '''
     This listens to a confirmation sent by one of the IPayment servers.
     Valid payments are commited as confirmed payments into their model.
     The intention of this view is not to display any useful information,
     since the HTTP-client is a server located at IPayment.
     '''
     if request.method != 'POST':
         return HttpResponseBadRequest()
     try:
         if settings.IPAYMENT['checkOriginatingIP']:
             self._check_originating_ipaddr(request)
         post = request.POST.copy()
         if 'trx_amount' in post:
             post['trx_amount'] = (Decimal(post['trx_amount']) / Decimal('100')) \
                                                 .quantize(Decimal('0.00'))
         if 'ret_transdate' and 'ret_transtime' in post:
             post['ret_transdatetime'] = datetime.strptime(
                 post['ret_transdate'] + ' ' + post['ret_transtime'],
                 '%d.%m.%y %H:%M:%S')
         confirmation = ConfirmationForm(post)
         if not confirmation.is_valid():
             raise SuspiciousOperation('Confirmation by IPayment rejected: '
                         'POST data does not contain all expected fields.')
         if not settings.IPAYMENT['useSessionId']:
             self._check_ret_param_hash(request.POST)
         confirmation.save()
         order = self.shop.get_order_for_id(confirmation.cleaned_data['shopper_id'])
         self.logger.info('IPayment for %s confirmed %s', order,
                          confirmation.cleaned_data['ret_status'])
         if confirmation.cleaned_data['ret_status'] == 'SUCCESS':
             self.shop.confirm_payment(order, confirmation.cleaned_data['trx_amount'],
                 confirmation.cleaned_data['ret_trx_number'], self.backend_name)
         return HttpResponse('OK')
     except Exception as exception:
         # since this response is sent to IPayment, catch errors locally
         logging.error('POST data: ' + request.POST.__str__())
         logging.error(exception.__str__())
         traceback.print_exc()
         return HttpResponseServerError('Internal error in ' + __name__)