remove monthly pricing, display 20$ for monthly pricing

This commit is contained in:
Son NK 2019-08-19 21:28:17 +02:00
parent f03fb6edcb
commit 5ff317538c
6 changed files with 6 additions and 20 deletions

View File

@ -33,7 +33,6 @@ CLOUDWATCH_LOG_STREAM=local
# Stripe # Stripe
STRIPE_YEARLY_PLAN=to_fill STRIPE_YEARLY_PLAN=to_fill
STRIPE_MONTHLY_PLAN=to_fill
STRIPE_API=to_fill STRIPE_API=to_fill
STRIPE_SECRET_KEY=to_fill STRIPE_SECRET_KEY=to_fill

View File

@ -64,7 +64,6 @@ CLOUDWATCH_LOG_STREAM = os.environ["CLOUDWATCH_LOG_STREAM"]
STRIPE_API = os.environ["STRIPE_API"] # Stripe public key STRIPE_API = os.environ["STRIPE_API"] # Stripe public key
STRIPE_SECRET_KEY = os.environ["STRIPE_SECRET_KEY"] STRIPE_SECRET_KEY = os.environ["STRIPE_SECRET_KEY"]
STRIPE_YEARLY_PLAN = os.environ["STRIPE_YEARLY_PLAN"] STRIPE_YEARLY_PLAN = os.environ["STRIPE_YEARLY_PLAN"]
STRIPE_MONTHLY_PLAN = os.environ["STRIPE_MONTHLY_PLAN"]
# OpenID keys, used to sign id_token # OpenID keys, used to sign id_token
OPENID_PRIVATE_KEY_PATH = get_abs_path(os.environ["OPENID_PRIVATE_KEY_PATH"]) OPENID_PRIVATE_KEY_PATH = get_abs_path(os.environ["OPENID_PRIVATE_KEY_PATH"])

View File

@ -50,9 +50,7 @@
<div class="card"> <div class="card">
<div class="card-body text-center"> <div class="card-body text-center">
<div class="card-category">Premium</div> <div class="card-category">Premium</div>
<div class="display-4 my-6">$10/year</div> <div class="display-4 my-6">$20/year</div>
<div class="display-5 my-6">or</div>
<div class="display-4 my-6">$1/month</div>
<ul class="list-unstyled leading-loose"> <ul class="list-unstyled leading-loose">
<li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i> Infinite Emails</li> <li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i> Infinite Emails</li>
<li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i> Custom Alias</li> <li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i> Custom Alias</li>
@ -94,10 +92,6 @@
<input type="radio" class="custom-control-input" name="plan" value="yearly" checked> <input type="radio" class="custom-control-input" name="plan" value="yearly" checked>
<span class="custom-control-label">Yearly</span> <span class="custom-control-label">Yearly</span>
</label> </label>
<label class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="plan" value="monthly">
<span class="custom-control-label">Monthly</span>
</label>
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@ from flask import render_template, request, flash, redirect, url_for
from flask_login import login_required, current_user from flask_login import login_required, current_user
from stripe.error import CardError from stripe.error import CardError
from app.config import STRIPE_API, STRIPE_MONTHLY_PLAN, STRIPE_YEARLY_PLAN from app.config import STRIPE_API, STRIPE_YEARLY_PLAN
from app.dashboard.base import dashboard_bp from app.dashboard.base import dashboard_bp
from app.email_utils import notify_admin from app.email_utils import notify_admin
from app.extensions import db from app.extensions import db
@ -31,10 +31,8 @@ def pricing():
raise Exception("user email is already used on stripe!") raise Exception("user email is already used on stripe!")
if request.method == "POST": if request.method == "POST":
plan_str = request.form.get("plan") # either monthly or yearly plan_str = request.form.get("plan") # yearly
if plan_str == "monthly": if plan_str == "yearly":
plan = PlanEnum.monthly
elif plan_str == "yearly":
plan = PlanEnum.yearly plan = PlanEnum.yearly
else: else:
raise Exception("Plan must be either yearly or monthly") raise Exception("Plan must be either yearly or monthly")
@ -60,9 +58,7 @@ def pricing():
LOG.d("stripe customer %s", customer) LOG.d("stripe customer %s", customer)
current_user.stripe_customer_id = customer.id current_user.stripe_customer_id = customer.id
stripe_plan = ( stripe_plan = STRIPE_YEARLY_PLAN
STRIPE_MONTHLY_PLAN if plan == PlanEnum.monthly else STRIPE_YEARLY_PLAN
)
subscription = stripe.Subscription.create( subscription = stripe.Subscription.create(
customer=current_user.stripe_customer_id, customer=current_user.stripe_customer_id,
items=[{"plan": stripe_plan}], items=[{"plan": stripe_plan}],

View File

@ -82,7 +82,6 @@ class File(db.Model, ModelMixin):
class PlanEnum(enum.Enum): class PlanEnum(enum.Enum):
free = 0 free = 0
trial = 1 trial = 1
monthly = 2
yearly = 3 yearly = 3
@ -149,7 +148,7 @@ class User(db.Model, ModelMixin, UserMixin):
return False return False
def is_premium(self): def is_premium(self):
return self.plan in (PlanEnum.monthly, PlanEnum.yearly) return self.plan == PlanEnum.yearly
def can_create_custom_email(self): def can_create_custom_email(self):
if self.is_premium(): if self.is_premium():

View File

@ -33,7 +33,6 @@ CLOUDWATCH_LOG_STREAM=local
# Stripe # Stripe
STRIPE_YEARLY_PLAN=to_fill STRIPE_YEARLY_PLAN=to_fill
STRIPE_MONTHLY_PLAN=to_fill
STRIPE_API=to_fill STRIPE_API=to_fill
STRIPE_SECRET_KEY=to_fill STRIPE_SECRET_KEY=to_fill