コード例 #1
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])
コード例 #2
0
ファイル: views.py プロジェクト: stermedia/django-getpaid
    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()
コード例 #3
0
ファイル: views.py プロジェクト: dcondeurra/django-getpaid
    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()
コード例 #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
ファイル: __init__.py プロジェクト: ra3sad/ExpertBilling
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
ファイル: __init__.py プロジェクト: ra3sad/ExpertBilling
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
ファイル: views.py プロジェクト: hoongun/django-getpaid
    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 プロジェクト: 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()
コード例 #9
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,
コード例 #10
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
コード例 #11
0
ファイル: views.py プロジェクト: Coalas/django-getpaid
 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)