Ejemplo n.º 1
0
    def _pay(self, id):
        payment = Payment.find_by_id(self.form_result['payment_id'])
        c.invoice = payment.invoice
        person = c.invoice.person

        if not h.auth.authorized(
                h.auth.Or(h.auth.is_same_zkpylons_user(person.id),
                          h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        error = self._check_invoice(person, c.invoice)
        if error is not None:
            return error

        client_ip = request.environ['REMOTE_ADDR']
        if 'HTTP_X_FORWARDED_FOR' in request.environ:
            client_ip = request.environ['HTTP_X_FORWARDED_FOR']

        # Prepare fields for PxPay
        params = {
            'payment_id': payment.id,
            'amount': h.integer_to_currency(payment.amount),
            'invoice_id': payment.invoice.id,
            'email_address': payment.invoice.person.email_address,
            'client_ip': client_ip,
            'return_url': 'https://conf.linux.org.au/payment/new',
        }

        (valid, uri) = pxpay.generate_request(params)
        if valid != '1':
            c.error_msg = "PxPay Generate Request error: " + uri
            return render("/payment/gateway_error.mako")
        else:
            redirect(uri)
Ejemplo n.º 2
0
    def _pay(self, id):
        payment = Payment.find_by_id(self.form_result['payment_id'])
        c.invoice = payment.invoice
        person = c.invoice.person

        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(person.id), h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        error = self._check_invoice(person, c.invoice)
        if error is not None:
            return error

        client_ip = request.environ['REMOTE_ADDR']
        if 'HTTP_X_FORWARDED_FOR' in request.environ:
            client_ip = request.environ['HTTP_X_FORWARDED_FOR']

        # Prepare fields for PxPay
        params = {
            'payment_id': payment.id,
            'amount': h.integer_to_currency(payment.amount),
            'invoice_id': payment.invoice.id,
            'email_address': payment.invoice.person.email_address,
            'client_ip' : client_ip,
            'return_url' : 'https://conf.linux.org.au/payment/new',
        }

        (valid, uri) = pxpay.generate_request(params)
        if valid != '1':
            c.error_msg = "PxPay Generate Request error: " + uri
            return render("/payment/gateway_error.mako")
        else:
            redirect(uri)
Ejemplo n.º 3
0
    def pay(self, id):
        """Request confirmation from user
        """
        invoice = Invoice.find_by_id(id, True)
        person = invoice.person

        if not h.auth.authorized(
                h.auth.Or(h.auth.is_same_zkpylons_user(person.id),
                          h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        #return render('/registration/really_closed.mako')

        error = self._check_invoice(person, invoice)
        if error is not None:
            return error

        c.payment = Payment()
        c.payment.amount = invoice.total
        c.payment.invoice = invoice

        meta.Session.commit()
        if c.payment.gateway == 'securepay':
            return render("/invoice/securepay.mako")
        else:
            return render("/invoice/payment.mako")
Ejemplo n.º 4
0
    def pay_invoice(self):
        """
        Pay an invoice via the new angular.js interface

        Expects: and invoice_id. Assumes total amount is to be paid.

        TODO: Validation??
        """
        invoice_id = int(request.params['invoice'],10)
        invoice = Invoice.find_by_id(invoice_id, True)
        person = invoice.person

        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(person.id), h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        payment = Payment()
        payment.amount = invoice.total
        payment.invoice = invoice

        payment_received = PaymentReceived(
                                    approved=True,
                                    payment=payment,
                                    invoice_id=invoice.id,
                                    success_code='0',
                                    amount_paid=payment.amount,
                                    currency_used='AUD',
                                    response_text='Approved',
                                    client_ip_zookeepr='127.1.0.1',
                                    client_ip_gateway='127.0.0.1',
                                    email_address=person.email_address,
                                    gateway_ref='Rego Desk Cash'
                    )

        meta.Session.add(payment)
        meta.Session.add(payment_received)
        meta.Session.commit()

        return "Payment recorded"
Ejemplo n.º 5
0
    def pay_invoice(self, id):
        """
        Pay an invoice via the new angular.js interface

        Expects: invoice_id. Assumes total amount is to be paid.

        TODO: Validation??
        """
        invoice = Invoice.find_by_id(id, True)
        person = invoice.person
        if not invoice.is_paid:
            payment = Payment()
            payment.amount = invoice.total
            payment.invoice = invoice

            payment_received = PaymentReceived(
                approved=True,
                payment=payment,
                invoice_id=invoice.id,
                success_code='0',
                amount_paid=payment.amount,
                currency_used='AUD',
                response_text='Approved',
                client_ip_zookeepr='127.1.0.1',
                client_ip_gateway='127.0.0.1',
                email_address=person.email_address,
                gateway_ref='Rego Desk Cash')

            meta.Session.add(payment)
            meta.Session.add(payment_received)
            meta.Session.commit()

            return dict(r=dict(message="Payment recorded"))
        else:
            return dict(r=dict(
                message="A payment has already been recorded for this invoice")
                        )
Ejemplo n.º 6
0
    def pay_invoice(self, id):
        """
        Pay an invoice via the new angular.js interface

        Expects: invoice_id. Assumes total amount is to be paid.

        TODO: Validation??
        """
        invoice = Invoice.find_by_id(id, True)
        person = invoice.person
        if not invoice.is_paid:
            payment = Payment()
            payment.amount = invoice.total
            payment.invoice = invoice

            payment_received = PaymentReceived(
                                        approved=True,
                                        payment=payment,
                                        invoice_id=invoice.id,
                                        success_code='0',
                                        amount_paid=payment.amount,
                                        currency_used='AUD',
                                        response_text='Approved',
                                        client_ip_zookeepr='127.1.0.1',
                                        client_ip_gateway='127.0.0.1',
                                        email_address=person.email_address,
                                        gateway_ref='Rego Desk Cash'
                        )

            meta.Session.add(payment)
            meta.Session.add(payment_received)
            meta.Session.commit()

            return dict(r=dict(message="Payment recorded"))
        else:
            return dict(r=dict(message="A payment has already been recorded for this invoice"))
Ejemplo n.º 7
0
    def pay_manual(self, id):
        """Request confirmation from user
        """
        invoice = Invoice.find_by_id(id, True)
        person = invoice.person

        error = self._check_invoice(person, invoice, ignore_overdue=True)
        if error is not None:
            return error

        c.payment = Payment()
        c.payment.amount = invoice.total
        c.payment.invoice = invoice

        meta.Session.commit()
        return redirect_to(controller='payment', id=c.payment.id, action='new_manual')