예제 #1
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")
예제 #2
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')
예제 #3
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"
예제 #4
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")
                        )