Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,6 @@ def get_env_csv(env_var: str, default: Optional[str]) -> list[str]:
# list of no reply addresses
NOREPLIES = sl_getenv("NOREPLIES", list) or [NOREPLY]

COINBASE_WEBHOOK_SECRET = os.environ.get("COINBASE_WEBHOOK_SECRET")
COINBASE_CHECKOUT_ID = os.environ.get("COINBASE_CHECKOUT_ID")
COINBASE_API_KEY = os.environ.get("COINBASE_API_KEY")
try:
COINBASE_YEARLY_PRICE = float(os.environ["COINBASE_YEARLY_PRICE"])
except Exception:
COINBASE_YEARLY_PRICE = 30.00

ALIAS_LIMIT = os.environ.get("ALIAS_LIMIT") or "100/day;50/hour;5/minute"

Expand Down
5 changes: 4 additions & 1 deletion app/dashboard/views/coupon.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def coupon_route():
coinbase_subscription: CoinbaseSubscription = CoinbaseSubscription.get_by(
user_id=current_user.id
)
if coinbase_subscription and coinbase_subscription.is_active():
# allow coinbase user to apply coupon 30d before their sub expires
if coinbase_subscription and coinbase_subscription.end_at > arrow.now().shift(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is sub ends is later than 30d in the future. I guess it should be

Suggested change
if coinbase_subscription and coinbase_subscription.end_at > arrow.now().shift(
if coinbase_subscription and coinbase_subscription.end_at > arrow.now() and coinbase_subscription.end_at < now.shit(days=30)

?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in person

days=30
):
can_use_coupon = False

if coupon_form.validate_on_submit():
Expand Down
22 changes: 0 additions & 22 deletions app/dashboard/views/pricing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import arrow
from coinbase_commerce import Client
from flask import render_template, flash, redirect, url_for
from flask_login import login_required, current_user

Expand All @@ -8,12 +7,8 @@
PADDLE_MONTHLY_PRODUCT_ID,
PADDLE_YEARLY_PRODUCT_ID,
URL,
COINBASE_YEARLY_PRICE,
COINBASE_API_KEY,
)
from app.dashboard.base import dashboard_bp
from app.extensions import limiter
from app.log import LOG
from app.models import (
AppleSubscription,
Subscription,
Expand Down Expand Up @@ -83,20 +78,3 @@ def subscription_success():
return render_template(
"dashboard/thank-you.html",
)


@dashboard_bp.route("/coinbase_checkout")
@login_required
@limiter.limit("5/minute")
def coinbase_checkout_route():
client = Client(api_key=COINBASE_API_KEY)
charge = client.charge.create(
name="1 Year SimpleLogin Premium Subscription",
local_price={"amount": str(COINBASE_YEARLY_PRICE), "currency": "USD"},
pricing_type="fixed_price",
metadata={"user_id": current_user.id},
)

LOG.d("Create coinbase charge %s", charge)

return redirect(charge["hosted_url"])
121 changes: 0 additions & 121 deletions app/payments/coinbase.py

This file was deleted.

3 changes: 0 additions & 3 deletions cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ def notify_manual_sub_end():
retries=3,
)

extend_subscription_url = config.URL + "/dashboard/coinbase_checkout"
for coinbase_subscription in CoinbaseSubscription.all():
need_reminder = False
if (
Expand Down Expand Up @@ -275,13 +274,11 @@ def notify_manual_sub_end():
"transactional/coinbase/reminder-subscription.txt",
user=user,
coinbase_subscription=coinbase_subscription,
extend_subscription_url=extend_subscription_url,
),
render(
"transactional/coinbase/reminder-subscription.html",
user=user,
coinbase_subscription=coinbase_subscription,
extend_subscription_url=extend_subscription_url,
),
retries=3,
)
Expand Down
2 changes: 0 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
from app.newsletter_utils import send_newsletter_to_user
from app.oauth.base import oauth_bp
from app.onboarding.base import onboarding_bp
from app.payments.coinbase import setup_coinbase_commerce
from app.payments.paddle import setup_paddle_callback
from app.phone.base import phone_bp
from app.redis_services import initialize_redis_services
Expand Down Expand Up @@ -154,7 +153,6 @@ def create_app() -> Flask:

init_admin(app)
setup_paddle_callback(app)
setup_coinbase_commerce(app)
setup_do_not_track(app)
register_custom_commands(app)

Expand Down
2 changes: 1 addition & 1 deletion templates/dashboard/coupon.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1 class="h2">Coupon</h1>
<div class="mb-4">Please enter the coupon here to upgrade your account or extend your current subscription.</div>
<form method="post">
{{ coupon_form.csrf_token }}
{{ coupon_form.code(class="form-control", placeholder="Licence Code") }}
{{ coupon_form.code(class="form-control", placeholder="Coupon Code") }}
{{ render_field_errors(coupon_form.code) }}
<button class="btn btn-success mt-2">Apply</button>
</form>
Expand Down
27 changes: 3 additions & 24 deletions templates/dashboard/pricing.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,29 +452,6 @@ <h5 class="mb-0 w-100">
Paddle supported payment methods <i class="fe fe-external-link"></i>
</a>.
</p>
<hr />
<p>
Furthermore we also support cryptocurrencies for the yearly plan via
<a href="https://commerce.coinbase.com"
target="_blank"
rel="noopener noreferrer">
Coinbase Commerce <i class="fe fe-external-link"></i>
</a>, which currently supports Bitcoin, Bitcoin Cash, DAI, ApeCoin, Dogecoin, Ethereum, Litecoin, SHIBA INU, Tether and USD Coin.
</p>
<p>
In the future, we are going to support Monero as well. In the meantime, please send us an email at <a href="mailto:support@simplelogin.zendesk.com" target="_blank">support@simplelogin.zendesk.com</a> if you want to use this cryptocurrency.
</p>
<div class="d-flex justify-content-center">
<a class="btn btn-outline-primary text-center"
href="{{ url_for("dashboard.coinbase_checkout_route") }}"
target="_blank"
rel="noopener noreferrer">
Upgrade to Premium - cryptocurrency
<br />
$36 / year
<i class="fe fe-external-link"></i>
</a>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -706,7 +683,9 @@ <h5 class="mb-0 w-100">
data-parent="#pricing-faq">
<div class="card-body">
<p>
Yes you can also buy SimpleLogin subscription coupon via <a href="https://proxysto.re/en/index.html" target="_blank">ProxyStore <i class="fe fe-external-link"></i></a>, our official reseller.
Yes you can also buy SimpleLogin subscription coupon via
<a href="https://digitalgoods.proxysto.re/en" target="_blank">ProxyStore <i class="fe fe-external-link"></i></a>,
our official reseller. They support Monero, Bitcoin, Cash and more.
</p>
</div>
</div>
Expand Down
5 changes: 0 additions & 5 deletions templates/dashboard/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@
<div>
Yearly plan subscribed with cryptocurrency which expires on
{{ coinbase_sub.end_at.format("YYYY-MM-DD") }}.
<a href="{{ url_for("dashboard.coinbase_checkout_route") }}"
target="_blank"
rel="noopener noreferrer">
Extend Subscription <i class="fe fe-external-link"></i>
</a>
</div>
{% endif %}
{% if partner_sub %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ <h1>Your subscription is ending soon.</h1>
<b>{{ coinbase_subscription.end_at.format("YYYY-MM-DD") }}</b>
{% endcall %}

{{ render_button("Extend your subscription", extend_subscription_url) }}
{% call text() %}
Due to Coinbase removing Coinbase Commerce, which SimpleLogin had been using until now,
you can no longer extend your subscription using cryptocurrency.
{% endcall %}

{% call text() %}
Please <a href="https://app.simplelogin.io/dashboard/support">contact us</a>
to renew your subscription.
{% endcall %}

{{ render_text('Best,
<br />
SimpleLogin Team.') }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Your subscription ends on {{ coinbase_subscription.end_at.format("YYYY-MM-DD") }}

You can extend your subscription on
{{ extend_subscription_url }}
Due to Coinbase removing Coinbase Commerce, which SimpleLogin had been using until now,
you can no longer extend your subscription using cryptocurrency.

Please contact us on https://app.simplelogin.io/dashboard/support to renew your subscription.

Best,
SimpleLogin team.
46 changes: 0 additions & 46 deletions tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import arrow

from app.config import EMAIL_DOMAIN
from app.db import Session
from app.models import CoinbaseSubscription
from app.payments.coinbase import handle_coinbase_event
from tests.utils import create_new_user


def test_redirect_login_page(flask_client):
Expand All @@ -13,43 +7,3 @@ def test_redirect_login_page(flask_client):
rv = flask_client.get("/")
assert rv.status_code == 302
assert rv.location == f"http://{EMAIL_DOMAIN}/auth/login"


def test_coinbase_webhook(flask_client):
r = flask_client.post("/coinbase")
assert r.status_code == 400


def test_handle_coinbase_event_new_subscription(flask_client):
user = create_new_user()
handle_coinbase_event(
{"data": {"code": "AAAAAA", "metadata": {"user_id": str(user.id)}}}
)

assert user.is_paid()
assert user.is_premium()

assert CoinbaseSubscription.get_by(user_id=user.id) is not None


def test_handle_coinbase_event_extend_subscription(flask_client):
user = create_new_user()
user.trial_end = None
Session.commit()

cb = CoinbaseSubscription.create(
user_id=user.id, end_at=arrow.now().shift(days=-400), commit=True
)
assert not cb.is_active()

assert not user.is_paid()
assert not user.is_premium()

handle_coinbase_event(
{"data": {"code": "AAAAAA", "metadata": {"user_id": str(user.id)}}}
)

assert user.is_paid()
assert user.is_premium()

assert CoinbaseSubscription.get_by(user_id=user.id) is not None
Loading