{% extends "meta.html" %}
{% block title %}
<title>Billing - {{cfg("sr.ht", "site-name")}} meta</title>
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
<h3>Billing Information</h3>
{% if message %}
<div class="alert alert-info">{{message}}</div>
{% endif %}
{% if current_user.user_type == UserType.active_non_paying %}
<div class="alert alert-info">
You are currently using an <strong>unpaid</strong>
{{cfg("sr.ht", "site-name")}} account. Some site features may be
unavailable to your account.
</div>
{% elif current_user.user_type == UserType.active_free %}
<div class="alert alert-info">
Your account is <strong>exempt</strong> from billing. All features are
available to you free of charge. You may choose to set up billing
if you wish to support the site.
</div>
{% elif current_user.user_type == UserType.active_paying %}
{% if current_user.payment_cents == 0 %}
<div class="alert alert-warning">
Your paid service has been cancelled. At the end of your current term,
{{current_user.payment_due | date}}, your account will be downgraded to a
non-paying account.
</div>
{% else %}
<div class="alert alert-success">
{% if invoices %}
Your account is <strong>paid</strong> and up-to-date, and your last
payment of {{"${:.2f}".format(invoices[0].cents/100)}}
was made {{invoices[0].created | date}}. Your current
{{current_user.payment_interval.value}} payment is
{{"${:.2f}".format(current_user.payment_cents/100
if current_user.payment_interval.value == "monthly"
else current_user.payment_cents*10/100)}} and will be billed
{{invoices[0].valid_thru | date}}.
{% else %}
Your account is <strong>paid</strong> and up-to-date. Your
current {{current_user.payment_interval.value}} payment is
{{"${:.2f}".format(current_user.payment_cents/100
if current_user.payment_interval.value == "monthly"
else current_user.payment_cents*10/100)}}.
{% endif %}
</div>
{% endif %}
{% elif current_user.user_type == UserType.active_delinquent %}
<div class="alert alert-danger">
<strong>Notice</strong>: Your payment is past due. Please check that your
payment information is correct or your service may be impacted.
</div>
{% elif current_user.user_type == UserType.admin %}
<div class="alert alert-info">
Admins are exempt from billing.
</div>
{% endif %}
<div style="margin-bottom: 1rem">
<div class="progress">
<div class="progress-bar"
role="progressbar"
style="width: {{paid_pct}}%;"
aria-valuenow="{{paid_pct}}"
aria-valuemin="0" aria-valuemax="100"
>{{paid_pct}}% paid</div>
<div
class="goal"
style="left: 13.37%"
title="Presented without comment"
>13.37%</div>
<div class="progress-bar total">of {{total_users}} registered users</div>
</div>
<small class="text-muted pull-right">
Current number of paid accounts on {{cfg("sr.ht", "site-name")}}
</small>
</div>
</div>
</div>
{% if current_user.user_type == UserType.active_paying
and current_user.payment_cents != 0 %}
<div class="row" style="margin-bottom: 1rem">
<div class="col-md-3 offset-md-6">
<a
href="{{url_for("billing.billing_initial_GET")}}"
class="btn btn-default btn-block"
>Change your plan {{icon('caret-right')}}</a>
</div>
<div class="col-md-3">
<form method="POST" action="{{url_for("billing.cancel_POST")}}">
{{csrf_token()}}
<button class="btn btn-danger btn-block">
Cancel your plan {{icon('caret-right')}}
</button>
</form>
</div>
</div>
{% elif current_user.user_type == UserType.active_delinquent %}
<div class="row" style="margin-bottom: 1rem">
<div class="col-md-3 offset-md-3">
<a
href="{{url_for("billing.billing_initial_GET")}}"
class="btn btn-default btn-block"
>Change your plan {{icon('caret-right')}}</a>
</div>
<div class="col-md-3">
<form method="POST" action="{{url_for("billing.cancel_POST")}}">
{{csrf_token()}}
<button class="btn btn-danger btn-block">
Cancel your plan {{icon('caret-right')}}
</button>
</form>
</div>
<div class="col-md-3">
<a
href="{{url_for("billing.new_payment_GET")}}"
class="btn btn-primary btn-block"
>Add payment method {{icon('caret-right')}}</a>
</div>
</div>
{% elif current_user.user_type == UserType.active_paying
and current_user.payment_cents == 0 %}
<div class="row" style="margin-bottom: 1rem">
<div class="col-md-3 offset-md-9">
<a
href="{{url_for("billing.billing_initial_GET")}}"
class="btn btn-primary btn-block"
>Renew your account {{icon('caret-right')}}</a>
</div>
</div>
{% elif current_user.user_type in [
UserType.active_non_paying,
UserType.active_free
] %}
<div class="row" style="margin-bottom: 1rem">
<div class="col-md-3 offset-md-9">
<a
href="{{url_for("billing.billing_initial_GET")}}"
class="btn btn-primary btn-block"
>Set up billing {{icon('caret-right')}}</a>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-md-6">
{% if current_user.user_type in [
UserType.active_paying,
UserType.active_delinquent
] %}
<h3>Payment methods</h3>
<div class="event-list">
{% for source in customer.sources %}
<div class="event row">
<div class="col-md-8">
{{source.brand}} ending in {{source.last4}}
<br />
<span class="text-muted">
{% if source.address_zip %}
Post code {{source.address_zip}}.
{% endif %}
Expires {{source.exp_month}}/{{source.exp_year}}.
</span>
</div>
<div class="col-md-4">
<div style="text-align: right">
{% if source.stripe_id == customer.default_source %}
{{icon('check', cls="text-success")}} Default
{% else %}
<form style="margin: 0;" method="POST"
action="{{url_for("billing.payment_source_remove",
source_id=source.id)}}">
{{csrf_token()}}
<button class="btn btn-link">
Remove {{icon('times')}}
</button>
</form>
<form method="POST"
action="{{url_for("billing.payment_source_make_default",
source_id=source.id)}}">
{{csrf_token()}}
<button class="btn btn-link">
Make default {{icon('caret-right')}}
</button>
</form>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<a
href="{{url_for("billing.new_payment_GET")}}"
class="btn btn-primary pull-right"
>New payment method {{icon('caret-right')}}</a>
{% endif %}
</div>
{% if len(invoices) != 0 %}
<div class="col-md-6">
<h3>Invoices</h3>
<div class="event-list">
{% for invoice in invoices %}
<div class="event invoice">
<h4>
<small class="text-success" style="margin-left: 0">
{{icon('check')}}
</small>
${{"{:.2f}".format(invoice.cents/100)}}
<small>
with {{invoice.source}}
</small>
<small>
<a
class="pull-right"
href="{{url_for("billing.invoice_GET", invoice_id=invoice.id)}}"
>Export as PDF</a>
</small>
</h4>
<p>
Paid {{invoice.created | date}}<br />
Valid for service until {{invoice.valid_thru | date}}
{% if invoice.comment %}
<br />
{{invoice.comment}}
{% endif %}
</p>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endblock %}