diff --git a/packages/backend/apps/finances/signals.py b/packages/backend/apps/finances/signals.py index 99e5b4087..ea8dfc61b 100644 --- a/packages/backend/apps/finances/signals.py +++ b/packages/backend/apps/finances/signals.py @@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model from django.db.models.signals import post_save from django.dispatch import receiver +from django.conf import settings from stripe.error import AuthenticationError from .services import subscriptions @@ -15,6 +16,9 @@ @receiver(post_save, sender=User) def create_free_plan_subscription(sender, instance, created, **kwargs): + if not settings.STRIPE_ENABLED: + return + if created: try: subscriptions.initialize_user(user=instance) diff --git a/packages/backend/config/settings.py b/packages/backend/config/settings.py index 72c4cb2d8..fc09a75dc 100644 --- a/packages/backend/config/settings.py +++ b/packages/backend/config/settings.py @@ -271,8 +271,9 @@ TASKS_BASE_HANDLER = env("TASKS_BASE_HANDLER", default="common.tasks.Task") TASKS_LOCAL_URL = env("TASKS_LOCAL_URL", default=None) -STRIPE_LIVE_SECRET_KEY = env("STRIPE_LIVE_SECRET_KEY", default="") -STRIPE_TEST_SECRET_KEY = env("STRIPE_TEST_SECRET_KEY", default="") + +STRIPE_LIVE_SECRET_KEY = env("STRIPE_LIVE_SECRET_KEY", default="sk_") +STRIPE_TEST_SECRET_KEY = env("STRIPE_TEST_SECRET_KEY", default="sk_test_") STRIPE_LIVE_MODE = env.bool("STRIPE_LIVE_MODE", default=False) DJSTRIPE_WEBHOOK_SECRET = env("DJSTRIPE_WEBHOOK_SECRET", default="") DJSTRIPE_FOREIGN_KEY_TO_FIELD = "id" @@ -281,6 +282,8 @@ if not STRIPE_CHECKS_ENABLED: SILENCED_SYSTEM_CHECKS.append("djstripe.C001") +STRIPE_ENABLED = '' not in STRIPE_LIVE_SECRET_KEY or '' not in STRIPE_TEST_SECRET_KEY + SUBSCRIPTION_TRIAL_PERIOD_DAYS = env("SUBSCRIPTION_TRIAL_PERIOD_DAYS", default=7) GRAPHENE = {