Only send internal cancelation emails if the user canceled themselves

In the other case (where payment failed), we already auto-email the customer
This commit is contained in:
Joseph Schorr 2017-06-16 14:27:55 -04:00
parent 37a6f1f5d9
commit 159badf7ed

View file

@ -46,8 +46,10 @@ def stripe_webhook():
change_type = '' change_type = ''
if event_type.endswith('.deleted'): if event_type.endswith('.deleted'):
plan_id = request_data['data']['object']['plan']['id'] plan_id = request_data['data']['object']['plan']['id']
change_type = 'canceled %s' % plan_id requested = bool(request_data.get('request'))
send_subscription_change(change_type, customer_id, cust_email, quay_username) if requested:
change_type = 'canceled %s' % plan_id
send_subscription_change(change_type, customer_id, cust_email, quay_username)
elif event_type.endswith('.created'): elif event_type.endswith('.created'):
plan_id = request_data['data']['object']['plan']['id'] plan_id = request_data['data']['object']['plan']['id']
change_type = 'subscribed %s' % plan_id change_type = 'subscribed %s' % plan_id