Пример #1
0
    def post(self):
        data = flatten_arguments(self.request.arguments)
        from models import Transaction, Invoice
        from pprint import pformat

        invoice_id = data.get('invoice')
        if invoice_id:
            invoice = Invoice.get_by_id(int(invoice_id, 10))

            txn = Transaction(invoice=invoice)
            txn.identifier = data.get('txn_id')
            txn.subscription_id = data.get("subscr_id")
            txn.transaction_type = data.get('txn_type')
            txn.currency = data.get('mc_currency')
            txn.amount = data.get('mc_gross', data.get('mc_amount3'))
            txn.data = pformat(data)
            txn.put()

            if self.verify(data):
                r = self.process(data, txn=txn, invoice=invoice)
            else:
                r = self.process_invalid(data, txn=txn, invoice=invoice)
            if r:
                self.write(r)
            else:
                self.write('Nothing to see here.')
        else:
            # error.  invoice id was not found.
            pass