Skip to content

Commit

Permalink
Clean up payment lifecycle emails
Browse files Browse the repository at this point in the history
  • Loading branch information
hdoupe committed Oct 3, 2019
1 parent 5fde0bb commit 0e7694d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ services:
- LOCAL=True
- BUCKET=cs-outputs-dev-1
- MAILGUN_API_KEY=${MAILGUN_API_KEY}
- USE_STRIPE=${USE_STRIPE}
- STRIPE_SECRET=${STRIPE_SECRET}
- WEBHOOK_SECRET=${WEBHOOK_SECRET}
ports:
- "8000:8000"
container_name: web
Expand Down
20 changes: 7 additions & 13 deletions webapp/apps/billing/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@

def invoice_payment_failed(event, link="test"):
print("processing invoice.payment_failed event...")
print("sending mail...")
user = event.customer.user
if hasattr(user, "email"):
target_email = user.email
else:
target_email = "[email protected]"
send_mail(
"Your Payment Failed",
f"Please pay the invoice at: {link}",
"[email protected]",
[target_email],
"Compute Studio",
"Payment failed",
"Compute Studio <[email protected]>",
["[email protected]"],
fail_silently=False,
)

Expand All @@ -33,9 +27,9 @@ def customer_created(event):
print("processing customer.created event...")
customer = Customer.objects.get(stripe_id=event.data["object"]["id"])
send_mail(
"Welcome to Compute Studio",
"Thanks for joining!",
"[email protected]",
"Compute Studio",
"Your payment method was set successfully! Please write back if you have any questions.",
"Compute Studio <[email protected]>",
[customer.user.email],
fail_silently=False,
)
Expand Down

0 comments on commit 0e7694d

Please sign in to comment.