Repository: mozmeao/basket

Issue:
New SubHub Event to monitor - when Fx Acct is deleted, cancel subscription
When a user deletes their Firefox Account, we need to send that info to Salesforce so that we can send a cancellation email to them. 

The mappings are similar to the cancellation of a subscription and can be found here: 
https://docs.google.com/spreadsheets/d/1z6aXj_9GUpl5g_hR2k_SmjY5tyhxvnoHGOr8e-cbo18/edit#gid=2141319461

The main difference is the Sales Stage, which will be set to "Account Deleted" 



Discussion:
@desiree-mofo I don't have access to that spreadsheet. 
@pmac - shared with both of your Google ID's (my apologies)
So I should add this opportunity object when I get the event from FxA that the account has been deleted, or there will be a new event from subhub for this?
The event to look for is customer.deleted - it's a new event that SubHub is sending over
Any details on what data might be in that event?
the mappings are in the spreadsheet (https://docs.google.com/spreadsheets/d/1z6aXj_9GUpl5g_hR2k_SmjY5tyhxvnoHGOr8e-cbo18/edit#gid=2141319461) on the "Deletion of FxA" tab - the stripe fields are mapped and any values you'll need to set in SFDC as defaults are listed there as well
 
got it. sorry I missed that bit. thanks!

Resolving patch:
diff --git a/basket/news/tasks.py b/basket/news/tasks.py
--- a/basket/news/tasks.py
+++ b/basket/news/tasks.py
@@ -815,16 +815,21 @@ def process_subhub_event_subscription_charge(data):
         statsd.incr('news.tasks.process_subhub_event.subscription_charge.user_not_found')
 
 
+SUB_STAGE_NAMES = {
+    'customer.subscription_cancelled': 'Subscription Canceled',
+    'customer.deleted': 'Account Deleted',
+}
+
+
 @et_task
 def process_subhub_event_subscription_cancel(data):
     """
-    Event name: customer.subscription_cancelled
+    Event name: customer.subscription_cancelled or customer.deleted
     """
     statsd.incr('news.tasks.process_subhub_event.subscription_cancel')
 
     user_data = get_user_data(payee_id=data['customer_id'],
                               extra_fields=['id'])
-
     if user_data:
         transaction_data = {
             'Amount': cents_to_dollars(data['plan_amount']),
@@ -839,7 +844,7 @@ def process_subhub_event_subscription_cancel(data):
             'PMT_Subscription_ID__c': data['subscription_id'],
             'RecordTypeId': settings.SUBHUB_OPP_RECORD_TYPE,
             'Service_Plan__c': data['nickname'],
-            'StageName': 'Subscription Canceled',
+            'StageName': SUB_STAGE_NAMES[data['event_type']],
         }
 
         sfdc.opportunity.create(transaction_data)
diff --git a/basket/news/views.py b/basket/news/views.py
--- a/basket/news/views.py
+++ b/basket/news/views.py
@@ -82,6 +82,7 @@
     'customer.source.expiring': process_subhub_event_credit_card_expiring,
     'customer.subscription.created': process_subhub_event_subscription_charge,  # subscriptioin creations & recurring charges
     'customer.subscription_cancelled': process_subhub_event_subscription_cancel,
+    'customer.deleted': process_subhub_event_subscription_cancel,
     'invoice.payment_failed': process_subhub_event_payment_failed,
 }
 AMO_SYNC_TYPES = {


Test patch: