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"
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") )
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"))