Skip to content
Snippets Groups Projects
Commit c68d980d authored by Pelle Koster's avatar Pelle Koster
Browse files

fix reading email recipients from config file, some additional logging

parent 2124152a
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,6 @@ from pathlib import Path ...@@ -15,8 +15,6 @@ from pathlib import Path
import dj_database_url import dj_database_url
from stripe_checkout.config import load_config
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parents[-2] BASE_DIR = Path(__file__).resolve().parents[-2]
...@@ -114,12 +112,6 @@ if DATABASE_URL: ...@@ -114,12 +112,6 @@ if DATABASE_URL:
} }
del 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_URL = "/admin/login/"
LOGIN_REDIRECT_URL = "/" LOGIN_REDIRECT_URL = "/"
......
...@@ -3,3 +3,4 @@ from .base import * # noqa: F401, F403 ...@@ -3,3 +3,4 @@ from .base import * # noqa: F401, F403
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
SECRET_KEY = "django-insecure-&_5fsv$%$hkv)$sjnt$+01vzzyur)$so*kjc&6vzm6rv%l%r+2" SECRET_KEY = "django-insecure-&_5fsv$%$hkv)$sjnt$+01vzzyur)$so*kjc&6vzm6rv%l%r+2"
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
import os
from django.apps import AppConfig from django.apps import AppConfig
from django.conf import settings
from stripe_checkout.config import load_config
class StripeCheckoutConfig(AppConfig): class StripeCheckoutConfig(AppConfig):
name = "stripe_checkout.stripe_checkout" 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)
...@@ -100,11 +100,13 @@ class Command(BaseCommand): ...@@ -100,11 +100,13 @@ class Command(BaseCommand):
return True return True
def _notify_unprocessed_payment(self, payment_intent: dict): 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 send_mail_to = settings.UNPROCESSED_PAYMENT_EMAIL_TO
if not send_mail_to: if not send_mail_to:
return False return False
if not isinstance(send_mail_to, list): if not isinstance(send_mail_to, list):
send_mail_to = [send_mail_to] send_mail_to = [send_mail_to]
self.stdout.write(f"Notfying {send_mail_to}")
send_mail( send_mail(
subject="Unrecognized payment in Stripe", subject="Unrecognized payment in Stripe",
...@@ -129,5 +131,8 @@ class Command(BaseCommand): ...@@ -129,5 +131,8 @@ class Command(BaseCommand):
order = Order.objects.filter(pk=order_id, visitor_id=visitor_id).first() order = Order.objects.filter(pk=order_id, visitor_id=visitor_id).first()
order.stripe_id = payment_intent["id"] order.stripe_id = payment_intent["id"]
order.save() order.save()
self.stdout.write(
f"Infered payment from visitor {visitor_id}, order {order_id}"
)
return order return order
return None return None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment