From fc8a0c3193a6b721546fc37f9335cda2ef80c7ff Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 24 Aug 2023 17:18:24 +1000 Subject: [PATCH] main: Cleaned up code --- README.md | 2 +- master/main.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a3364ac..1217cb8 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ SMTP_HOST: smtp-server SMTP_PORT: smtp-port SMTP_USER: smtp-user SMTP_PASS: smtp-pass -SMTP_FROM: smtp-from +SMTP_FROM: smtp-from (eg. HNSHosting ) This is optional ``` diff --git a/master/main.py b/master/main.py index 9384027..b5effa2 100644 --- a/master/main.py +++ b/master/main.py @@ -251,8 +251,7 @@ def stripeapi(): return jsonify({'success': 'false'}) except stripe.error.SignatureVerificationError as e: return jsonify({'success': 'false'}) - - # Handle the event + if event.type == 'payment_intent.succeeded': payment_intent = event.data.object # Get email @@ -270,12 +269,12 @@ def stripeapi(): password = os.getenv('SMTP_PASS') from_email = os.getenv('SMTP_FROM') if from_email == None: - from_email = user + from_email = "Hosting <"+user + ">" context = ssl.create_default_context() with smtplib.SMTP_SSL(host, port, context=context) as server: server.login(user, password) - message = "From: Hosting <" + from_email + ">\nTo: " + email + \ + message = "From: " + from_email + "\nTo: " + email + \ "\nSubject: Your Licence key\n\nHello,\n\n"\ +"This email contains your licence key for your new wordpress site.\n" \ +"You can redeem this key via the discord bot or api.\n\n"\ @@ -283,16 +282,12 @@ def stripeapi(): server.sendmail(from_email, email, message) - - - print('PaymentIntent was successful!', flush=True) + print('Licence sent via email for stripe payment', flush=True) else: print('Unhandled event type {}'.format(event.type)) return jsonify({'success': 'true'}) - - def get_sites_count(): # If file doesn't exist, create it try: