Exemple #1
0
    def get(self):
        # provide a blank form.
        template = JINJA_ENV.get_template('make.html')
        ctx = CKObject()
        ctx.valid_coins = ACCOUNT_MAP.keys()
        recent = MyInvoice.recent_invoices().fetch(40)
        ctx.recent_invoices = recent

        for inv in recent:
            if inv.paid_at != None:
                inv.text_status = 'PAID'
                continue

            # check if paid.
            try:
                d = get_ck_detail(inv.ck_refnum)
            except:
                logger.error("Failed on %s" % inv.ck_refnum, exc_info=1)
                continue

            inv.details = d
            if d.is_completed or d.amount_so_far.decimal:
                # TODO: should expose total paid so far (for tips and underpayment)
                # and link to transaction numbers displayed at blockr and so on.
                conf = d.events[0].confirmed_at
                if conf != None:
                    inv.paid_at = conf
                    inv.text_status = 'PAID'
                    inv.put_async()
                else:
                    inv.text_status = 'pending'
            else:
                inv.text_status = 'unpaid'

        self.response.write(template.render(ctx))
    def get(self):
        # provide a blank form.
        template = JINJA_ENV.get_template('make.html')
        ctx = CKObject()
        ctx.valid_coins = ACCOUNT_MAP.keys()
        recent = MyInvoice.recent_invoices().fetch(40)
        ctx.recent_invoices = recent

        for inv in recent:
            if inv.paid_at != None:
                inv.text_status = 'PAID'
                continue

            # check if paid.
            try:
                d = get_ck_detail(inv.ck_refnum)
            except:
                logger.error("Failed on %s" % inv.ck_refnum, exc_info=1)
                continue

            inv.details = d
            if d.is_completed or d.amount_so_far.decimal:
                # TODO: should expose total paid so far (for tips and underpayment)
                # and link to transaction numbers displayed at blockr and so on.
                conf = d.events[0].confirmed_at
                if conf != None:
                    inv.paid_at = conf
                    inv.text_status = 'PAID'
                    inv.put_async()
                else:
                    inv.text_status = 'pending'
            else:
                inv.text_status = 'unpaid'

        self.response.write(template.render(ctx))
Exemple #3
0
    def get(self, token, example='btc'):
        ctx = CKObject(max_time=MAX_PAY_TIME)
        if token == 'example':
            cct = example.upper()
            ctx.cct = cct
            ctx.payable = Decimal('0.1612')
            ctx.payable_cct = cct
            ctx.amount_cct = 'USD'
            ctx.amount = Decimal('100.00')
            ctx.show_fiat = True
            ctx.label = 'Doggy Dash Crypto Cash'
            ctx.pubkey = 'n1EeygjWd6WSWxMyUx8Y6RBts3Mo8aZr3S'
            ctx.time_left = 10 * 60
            ctx.is_paid = False
        else:
            # find in DB
            inv = MyInvoice.get_by_token(token)

            if not inv:
                ctx.token = token
                template = JINJA_ENV.get_template('missing.html')
                self.response.write(template.render(ctx))
                return

            ctx.update(inv.to_dict())
            cct = inv.payable_cct
            ctx.label = ctx.label or ''
            ctx.time_left = inv.get_time_left()

            d = get_ck_detail(inv.ck_refnum)
            print "details = %r" % d

            # Has it been paid?? Limitations here:
            # - should handle amounts less that desired total, for wallets that sometimes
            #   round down by a few satoshis.
            # - check # of confirmations are suitable for risk preferences
            #
            ctx.is_paid = d.is_completed or (d.amount_so_far.decimal >=
                                             ctx.payable)

            assert ctx.pubkey == d.coin.address

        if ctx.show_fiat:
            ctx.exchange_rates = [
                ('1 %s' % cct, '$612 USD'),
                ('%s %s' % (ctx.amount, cct), '$612 USD'),
            ]

        # a small dictionary of values we need to connect to pubnub
        ctx.pubnub_auth = get_pubnub_auth()

        ctx.bitcoin_link = ('bitcoin:%s?' % ctx.pubkey) + urlencode(
            dict(amount=ctx.amount, message=ctx.label[0:40]))

        template = JINJA_ENV.get_template('invoice.html')
        self.response.write(template.render(ctx))
    def get(self, token, example='btc'):
        ctx = CKObject(max_time = MAX_PAY_TIME)
        if token == 'example':
            cct = example.upper()
            ctx.cct = cct
            ctx.payable = Decimal('0.1612')
            ctx.payable_cct = cct
            ctx.amount_cct = 'USD'
            ctx.amount = Decimal('100.00')
            ctx.show_fiat = True
            ctx.label = 'Doggy Dash Crypto Cash'
            ctx.pubkey = 'n1EeygjWd6WSWxMyUx8Y6RBts3Mo8aZr3S'
            ctx.time_left = 10*60
            ctx.is_paid = False
        else:
            # find in DB
            inv = MyInvoice.get_by_token(token)

            if not inv:
                ctx.token = token
                template = JINJA_ENV.get_template('missing.html')
                self.response.write(template.render(ctx))
                return

            ctx.update(inv.to_dict())
            cct = inv.payable_cct
            ctx.label = ctx.label or ''
            ctx.time_left = inv.get_time_left()

            d = get_ck_detail(inv.ck_refnum)
            print "details = %r" % d

            # Has it been paid?? Limitations here:
            # - should handle amounts less that desired total, for wallets that sometimes
            #   round down by a few satoshis.
            # - check # of confirmations are suitable for risk preferences
            #
            ctx.is_paid = d.is_completed or (d.amount_so_far.decimal >= ctx.payable)

            assert ctx.pubkey == d.coin.address
            
        if ctx.show_fiat: 
            ctx.exchange_rates = [
                ('1 %s' % cct, '$612 USD'), 
                ('%s %s' % (ctx.amount, cct), '$612 USD'), 
            ]

        # a small dictionary of values we need to connect to pubnub
        ctx.pubnub_auth = get_pubnub_auth()

        ctx.bitcoin_link = ('bitcoin:%s?' % ctx.pubkey) + urlencode(dict(
                            amount = ctx.amount, message = ctx.label[0:40]))
    
        template = JINJA_ENV.get_template('invoice.html')
        self.response.write(template.render(ctx))