diff --git a/setup.py b/setup.py index 081cced6759ff1beacb6c2241045174aec6838b2..19ae8e4d62602888fc57dea9595e2f30b3c80961 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="stripe-checkout", - version="0.10", + version="0.11", author="GEANT", author_email="swd@geant.org", description="Stripe custom checkout support service", diff --git a/stripe_checkout/settings/base.py b/stripe_checkout/settings/base.py index c3f8c20d4717da30edc2a7644e30280a69b9c8af..0338f49cf539fc69d750b4d6b79ee999c8bffa3f 100644 --- a/stripe_checkout/settings/base.py +++ b/stripe_checkout/settings/base.py @@ -15,8 +15,6 @@ from pathlib import Path import dj_database_url -from stripe_checkout.config import load_config - # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parents[-2] @@ -114,12 +112,6 @@ if DATABASE_URL: } del DATABASE_URL -CONFIG_FILENAME = os.getenv("CONFIG_FILENAME") -if CONFIG_FILENAME: - load_config(CONFIG_FILENAME, globals()) -del CONFIG_FILENAME - - LOGIN_URL = "/admin/login/" LOGIN_REDIRECT_URL = "/" diff --git a/stripe_checkout/settings/dev.py b/stripe_checkout/settings/dev.py index 4c20c6221abc307b03662e3909f43709562568d1..e205e36320d76b66f0aa9e25036e28055531fbe6 100644 --- a/stripe_checkout/settings/dev.py +++ b/stripe_checkout/settings/dev.py @@ -3,3 +3,4 @@ from .base import * # noqa: F401, F403 # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True SECRET_KEY = "django-insecure-&_5fsv$%$hkv)$sjnt$+01vzzyur)$so*kjc&6vzm6rv%l%r+2" +EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" diff --git a/stripe_checkout/stripe_checkout/apps.py b/stripe_checkout/stripe_checkout/apps.py index 344e734c86bc15a0ded7fc2465902b4507040a80..1f77e5d547da7849bfff68f14012b0070b71f292 100644 --- a/stripe_checkout/stripe_checkout/apps.py +++ b/stripe_checkout/stripe_checkout/apps.py @@ -1,5 +1,18 @@ +import os from django.apps import AppConfig +from django.conf import settings + +from stripe_checkout.config import load_config class StripeCheckoutConfig(AppConfig): name = "stripe_checkout.stripe_checkout" + + def ready(self): + """The ready hook is called by django after initialization""" + + # We read the config file here so that we can override settings that are set + # in the settings file + config_filename = os.getenv("CONFIG_FILENAME") + if config_filename: + load_config(config_filename, settings) diff --git a/stripe_checkout/stripe_checkout/management/commands/processevents.py b/stripe_checkout/stripe_checkout/management/commands/processevents.py index 7753166d0991e4d210e5390fe5e2c5130fea23d4..fa1c0eaa53f21731d7017a4c281b3154448ab2f4 100644 --- a/stripe_checkout/stripe_checkout/management/commands/processevents.py +++ b/stripe_checkout/stripe_checkout/management/commands/processevents.py @@ -100,11 +100,13 @@ class Command(BaseCommand): return True def _notify_unprocessed_payment(self, payment_intent: dict): + self.stdout.write(f"Unrecognized payment {payment_intent['id']}") send_mail_to = settings.UNPROCESSED_PAYMENT_EMAIL_TO if not send_mail_to: return False if not isinstance(send_mail_to, list): send_mail_to = [send_mail_to] + self.stdout.write(f"Notfying {send_mail_to}") send_mail( subject="Unrecognized payment in Stripe", @@ -129,5 +131,8 @@ class Command(BaseCommand): order = Order.objects.filter(pk=order_id, visitor_id=visitor_id).first() order.stripe_id = payment_intent["id"] order.save() + self.stdout.write( + f"Infered payment from visitor {visitor_id}, order {order_id}" + ) return order return None