예제 #1
0
    def form_valid(self, form):
        from getpaid.models import Payment
        payment = Payment.create(form.cleaned_data['order'],
                                 form.cleaned_data['backend'])
        processor = payment.get_processor()(payment)
        gateway_url_tuple = processor.get_gateway_url(self.request)
        payment.change_status('in_progress')
        redirecting_to_payment_gateway_signal.send(
            sender=None,
            request=self.request,
            order=form.cleaned_data['order'],
            payment=payment,
            backend=form.cleaned_data['backend'])

        if gateway_url_tuple[1].upper() == 'GET':
            return HttpResponseRedirect(gateway_url_tuple[0])
        elif gateway_url_tuple[1].upper() == 'POST':
            context = self.get_context_data()
            context['gateway_url'] = processor.get_gateway_url(self.request)[0]
            context['form'] = processor.get_form(gateway_url_tuple[2])

            return TemplateResponse(request=self.request,
                                    template=self.get_template_names(),
                                    context=context)
        else:
            raise ImproperlyConfigured()
예제 #2
0
    def form_valid(self, form):
        from getpaid.models import Payment
        try:
            order_additional_validation\
                .send(sender=None, request=self.request,
                    order=form.cleaned_data['order'],
                    backend=form.cleaned_data['backend'])
        except ValidationError:
            return self.form_invalid(form)

        payment = Payment.create(form.cleaned_data['order'],
                                 form.cleaned_data['backend'])
        processor = payment.get_processor()(payment)
        gateway_url_tuple = processor.get_gateway_url(self.request)
        payment.change_status('in_progress')
        redirecting_to_payment_gateway_signal.send(sender=None,
            request=self.request, order=form.cleaned_data['order'],
            payment=payment, backend=form.cleaned_data['backend'])

        if gateway_url_tuple[1].upper() == 'GET':
            return HttpResponseRedirect(gateway_url_tuple[0])
        elif gateway_url_tuple[1].upper() == 'POST':
            context = self.get_context_data()
            context['gateway_url'] = \
                processor.get_gateway_url(self.request)[0]
            context['form'] = processor.get_form(gateway_url_tuple[2])

            return TemplateResponse(request=self.request,
                template=self.get_template_names(),
                context=context)
        else:
            raise ImproperlyConfigured()
예제 #3
0
 def form_valid(self, form):
     funding = form.save()
     # Skip getpaid.forms.PaymentMethodForm, go directly to the broker.
     payment = Payment.create(funding, self.backend)
     gateway_url_tuple = payment.get_processor()(payment).get_gateway_url(self.request)
     payment.change_status('in_progress')
     return redirect(gateway_url_tuple[0])
예제 #4
0
 def form_valid(self, form):
     funding = form.save()
     # Skip getpaid.forms.PaymentMethodForm, go directly to the broker.
     payment = Payment.create(funding, self.backend)
     gateway_url_tuple = payment.get_processor()(payment).get_gateway_url(
         self.request)
     payment.change_status('in_progress')
     return redirect(gateway_url_tuple[0])
예제 #5
0
class PaymentProcessor(PaymentProcessorBase):
    BACKEND = 'payments.paypro'
    BACKEND_NAME = _('PayPro backend')
    BACKEND_ACCEPTED_CURRENCY = ('RUB', )

    @staticmethod
    def error(body, text):

        return '%s' % text

    @staticmethod
    def compute_sig(body):
        return ''

    @staticmethod
    def pay(request, body):
        acc = body.get('account')
        orderid = body.get('pay_id')
        amount = body.get('pay_amount_all')
        check = body.get('check')
        date = body.get('date')

        try:
            account = Account.objects.get(contract=acc)
        except Account.DoesNotExist, ex:
            return PaymentProcessor.error(body, u'-1')

        try:
            amount = float(amount)
        except:
            return PaymentProcessor.error(body, u'-5')

        try:
            date = datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S')
        except:
            return PaymentProcessor.error(body, u'-5')

        if amount > 0:
            from getpaid.models import Payment

            print "amount=", amount, orderid
            payment = Payment.create(account,
                                     None,
                                     PaymentProcessor.BACKEND,
                                     amount=amount,
                                     external_id='%s-%s' % (orderid, check))
            dt = datetime.datetime.now()
            payment.paid_on = dt
            payment.amount_paid = payment.amount
            payment.save()
            payment.change_status('paid')
        return ''
예제 #6
0
class PaymentProcessor(PaymentProcessorBase):
    BACKEND = 'payments.simpleterminal'
    BACKEND_NAME = _('SimpleTerminal backend')
    BACKEND_ACCEPTED_CURRENCY = ('RUB', )

    @staticmethod
    def error(body, text):

        return '%s' % text

    @staticmethod
    def compute_sig(body):
        return ''

    @staticmethod
    def pay(request, body):
        acc = body.get('uid')
        orderid = body.get('trans')
        amount = body.get('sum')

        try:
            account = Account.objects.get(contract=acc)
        except Account.DoesNotExist, ex:
            return PaymentProcessor.error(body, u'-1')

        try:
            amount = float(amount)
        except:
            return PaymentProcessor.error(body, u'-5')

        if amount > 0:
            from getpaid.models import Payment

            print "amount=", amount, orderid
            payment = Payment.create(account,
                                     None,
                                     PaymentProcessor.BACKEND,
                                     amount=amount,
                                     external_id=orderid)
            dt = datetime.datetime.now()
            payment.paid_on = dt
            payment.amount_paid = payment.amount
            payment.save()
            payment.change_status('paid')
        return '0'
예제 #7
0
    def form_valid(self, form):
        from getpaid.models import Payment

        payment = Payment.create(form.cleaned_data["order"], form.cleaned_data["backend"])
        processor = payment.get_processor()(payment)
        gateway_url_tuple = processor.get_gateway_url(self.request)
        payment.change_status("in_progress")

        if gateway_url_tuple[1].upper() == "GET":
            return HttpResponseRedirect(gateway_url_tuple[0])
        elif gateway_url_tuple[1].upper() == "POST":
            context = self.get_context_data()
            context["gateway_url"] = processor.get_gateway_url(self.request)[0]
            context["form"] = processor.get_form(gateway_url_tuple[2])

            return TemplateResponse(request=self.request, template=self.get_template_names(), context=context)
        else:
            raise ImproperlyConfigured()
예제 #8
0
파일: views.py 프로젝트: EE/django-getpaid
    def form_valid(self, form):
        from getpaid.models import Payment
        order = form.cleaned_data['order']
        next_url, method, form, processor = Payment.run_payment(
            order, form.cleaned_data['backend'], request=self.request)
        if next_url is None and getattr(order, 'recurring', False):
            next_url = getattr(settings, 'GETPAID_SUCCESS_URL_NAME', None)
            return http.HttpResponseRedirect(reverse(next_url))

        if method.upper() == 'GET':
            return http.HttpResponseRedirect(next_url)
        elif method.upper() == 'POST':
            context = self.get_context_data()
            context['gateway_url'] = processor.get_gateway_url(self.request)[0]
            context['form'] = processor.get_form(form)

            return TemplateResponse(request=self.request,
                                    template=self.get_template_names(),
                                    context=context)
        else:
            raise ImproperlyConfigured()
예제 #9
0
파일: views.py 프로젝트: brat002/ebscab
    def form_valid(self, form):
        from getpaid.models import Payment

        payment = Payment.create(self.request.user.account, form.cleaned_data['order'], form.cleaned_data['backend'], amount = form.cleaned_data['summ'])
        processor = payment.get_processor()(payment)
        gateway_url_tuple = processor.get_gateway_url(self.request, payment)
        payment.change_status('in_progress')
        order = form.cleaned_data['order']
            
        redirecting_to_payment_gateway_signal.send(sender=None, request=self.request, order=order, payment=payment, backend=form.cleaned_data['backend'])

        if gateway_url_tuple[1].upper() == 'GET':
            return HttpResponseRedirect(gateway_url_tuple[0])
        elif gateway_url_tuple[1].upper() == 'POST':
            context = self.get_context_data()
            context['gateway_url'] = processor.get_gateway_url(self.request, payment)[0]
            context['form'] = processor.get_form(gateway_url_tuple[2])

            return TemplateResponse(request = self.request,
                template = "getpaid/payment_post_form.html",
                context = context)
        else:
            raise ImproperlyConfigured()
예제 #10
0
파일: views.py 프로젝트: brat002/ebscab
 def get_form(self, form_class=None):
     processor = Payment(backend = self.request.GET.get('backend') or self.request.POST.get('backend')).get_processor()
     a = self.get_form_kwargs()
     a.update({'initial': {'backend':self.request.GET.get('backend')}})
     return processor.form()(**a)
예제 #11
0
파일: __init__.py 프로젝트: brat002/ebscab
     service_id = body.request.payment.serviceId
     res = PaymentProcessor.check_service_id(body, service_id)
     if res is not None:
         return res
     
     try:
         account = Account.objects.get(contract = acc)
     except Account.DoesNotExist, ex:
         return PaymentProcessor.error(body, u'Аккаунт не найден')
     
     
     if amount>0:
         from getpaid.models import Payment
 
         print "amount=", amount
         payment = Payment.create(account, None,   PaymentProcessor.BACKEND, amount = amount, external_id=orderid)
     dt = datetime.datetime.now()
     ret = SUCCESS_PAY_TEMPLATE % {
                                      'STATUS': TransactionStatus.OK,
                                      'STATUS_DETAIL': u'Платёж создан. Требуется подтверждение',
                                      'DATETIME': dt.strftime('%Y-%m-%dT%H:%M:%S'),
                                      'PAYMENT_ID': payment.id,
                                      'SIGN': ''
                                      
                                      }
     SIGN = PaymentProcessor.compute_sig(ret)
     ret = SUCCESS_PAY_TEMPLATE % {
                                      'STATUS': TransactionStatus.OK,
                                      'STATUS_DETAIL': u'Платёж создан. Требуется подтверждение',
                                      'DATETIME': dt.strftime('%Y-%m-%dT%H:%M:%S'),
                                      'PAYMENT_ID': payment.id,
예제 #12
0
        acc = body.commandcall.account.text
        amount = float(body.commandcall.amount.text) / 100.00
        orderid = body.commandcall.payid.text
        timestamp = body.commandcall.paytimestamp.text

        try:
            account = Account.objects.get(contract=acc)
        except Account.DoesNotExist, ex:
            return PaymentProcessor.error(body, 5, u'Аккаунт не найден')

        if amount > 0:
            from getpaid.models import Payment

            payment = Payment.create(account,
                                     None,
                                     PaymentProcessor.BACKEND,
                                     amount=amount,
                                     external_id=orderid)
            payment.paid_on = datetime.datetime.strptime(
                timestamp, '%Y%m%d%H%M%S')
            payment.amount_paid = payment.amount
            payment.save()
            payment.change_status('paid')
            ret = SUCCESS_CHECK_TEMPLATE % {
                'TRANSACTION_ID': body.commandcall.transactionid.text,
                'RESULT': 0,
                'ACCOUNT': body.commandcall.account.text,
                'COMMENT': 'OK',
            }

            return ret
예제 #13
0
 def get_form(self, form_class=None):
     processor = Payment(backend = self.request.GET.get('backend') or self.request.POST.get('backend')).get_processor()
     return processor.form()(**self.get_form_kwargs())
예제 #14
0
 def form_valid(self, form):
     from getpaid.models import Payment
     payment = Payment.create(form.cleaned_data['order'], form.cleaned_data['backend'])
     gateway_url = payment.get_processor()(payment).get_gateway_url(self.request)
     payment.change_status('in_progress')
     return HttpResponseRedirect(gateway_url)
예제 #15
0
 def get_form(self, form_class=None):
     processor = Payment(
         backend=self.request.GET.get('backend')
         or self.request.POST.get('backend')).get_processor()
     return processor.form()(**self.get_form_kwargs())