Create extend_subscription page
This commit is contained in:
parent
794e7ca5b9
commit
436e31229f
|
@ -25,4 +25,5 @@ from .views import (
|
|||
contact_detail,
|
||||
setup_done,
|
||||
batch_import,
|
||||
extend_subscription,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{% extends 'default.html' %}
|
||||
|
||||
{% set active_page = "dashboard" %}
|
||||
|
||||
{% block title %}
|
||||
Extend Subscription
|
||||
{% endblock %}
|
||||
|
||||
{% block default_content %}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h1 class="h2">Extend Subscription</h1>
|
||||
|
||||
<p>
|
||||
Your subscription is expired on {{ coinbase_subscription.end_at.format("YYYY-MM-DD") }}
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<a class="buy-with-crypto" data-custom="{{ current_user.id }}"
|
||||
href="{{ coinbase_url }}">
|
||||
Extend for 1 yearly - $30
|
||||
</a>
|
||||
<script src="https://commerce.coinbase.com/v1/checkout.js?version=201807">
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
Your subscription will be extended when the payment is confirmed and we'll send you a confirmation email. <br>
|
||||
Please note that it can take up to 1h for processing a cryptocurrency payment.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,24 @@
|
|||
from flask import render_template, flash, redirect, url_for
|
||||
from flask_login import login_required, current_user
|
||||
|
||||
from app.config import COINBASE_CHECKOUT_ID
|
||||
from app.dashboard.base import dashboard_bp
|
||||
from app.models import CoinbaseSubscription
|
||||
|
||||
|
||||
@dashboard_bp.route("/extend_subscription", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def extend_subscription_route():
|
||||
coinbase_subscription = CoinbaseSubscription.get_by(user_id=current_user.id)
|
||||
# this page is only for user who has an active coinbase subscription
|
||||
if not coinbase_subscription or not coinbase_subscription.is_active():
|
||||
flash("Unknown error, redirect to home page", "error")
|
||||
return redirect(url_for("dashboard.index"))
|
||||
|
||||
coinbase_url = "https://commerce.coinbase.com/checkout/" + COINBASE_CHECKOUT_ID
|
||||
|
||||
return render_template(
|
||||
"dashboard/extend_subscription.html",
|
||||
coinbase_subscription=coinbase_subscription,
|
||||
coinbase_url=coinbase_url,
|
||||
)
|
Loading…
Reference in New Issue