def test_invoice_upcoming(self, mock_stripe): """ Parse out the data correctly from a Stripe invoice payload. """ parsed_payload = Invoice.upcoming('cus_000') next_bill_on = datetime.datetime(2015, 5, 30, 20, 46, 10) assert parsed_payload['plan'] == 'Gold' assert parsed_payload['description'] == 'GOLD MONTHLY' assert parsed_payload['next_bill_on'] == next_bill_on assert parsed_payload['amount_due'] == 500 assert parsed_payload['interval'] == 'month'
def billing_history(): invoices = Invoice.query.filter(Invoice.user_id == current_user.id) \ .order_by(Invoice.created_on.desc()).limit(12) if current_user.subscription: upcoming = Invoice.upcoming(current_user.payment_id) coupon = Coupon.query \ .filter(Coupon.code == current_user.subscription.coupon).first() else: upcoming = None coupon = None return render_template('billing/billing_history.jinja2', invoices=invoices, upcoming=upcoming, coupon=coupon)