Repository: mozmeao/basket

Issue:
Inactivate cc expiring trigger for Subscription services
As of Monday, May 4, subscription services email confirmations will be sent from the Firefox Accounts team vs. out of Salesforce. The email trigger for credit card expiration date approaching that is triggered by Basket should be inactivated. The other feeds should remain (initial purchase, recurring charge, payment failed, etc). The only trigger that needs to be disabled is the cc expiration date approaching that writes directly to a SFMC Data extension and triggers an email to the customer. 


Discussion:

Resolving patch:
diff --git a/basket/news/tasks.py b/basket/news/tasks.py
--- a/basket/news/tasks.py
+++ b/basket/news/tasks.py
@@ -1020,15 +1020,6 @@ def process_subhub_event_subscription_cancel(data):
         sfdc.update(user_data, {'fxa_deleted': True})
 
 
-@et_task
-def process_subhub_event_credit_card_expiring(data):
-    """
-    Event name: customer.source.expiring
-    """
-    statsd.incr('news.tasks.process_subhub_event.credit_card_expiring')
-    sfmc.send_mail(settings.SUBHUB_CC_EXPIRE_TRIGGER, data['email'], data['email'])
-
-
 @et_task
 def process_subhub_event_payment_failed(data):
     """
diff --git a/basket/news/views.py b/basket/news/views.py
--- a/basket/news/views.py
+++ b/basket/news/views.py
@@ -47,7 +47,6 @@
     update_user_meta,
     upsert_contact,
     upsert_user,
-    process_subhub_event_credit_card_expiring,
     process_subhub_event_customer_created,
     process_subhub_event_payment_failed,
     process_subhub_event_subscription_cancel,
@@ -90,7 +89,6 @@
 SUBHUB_EVENT_TYPES = {
     'customer.created': process_subhub_event_customer_created,
     'customer.recurring_charge': process_subhub_event_subscription_charge,  # subscriptioin creations & recurring charges
-    '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.subscription.reactivated': process_subhub_event_subscription_reactivated,


Test patch:
diff --git a/basket/news/tests/test_tasks.py b/basket/news/tests/test_tasks.py
--- a/basket/news/tests/test_tasks.py
+++ b/basket/news/tests/test_tasks.py
@@ -33,7 +33,6 @@
     process_donation,
     process_donation_event,
     process_petition_signature,
-    process_subhub_event_credit_card_expiring,
     process_subhub_event_customer_created,
     process_subhub_event_payment_failed,
     process_subhub_event_subscription_cancel,
@@ -362,7 +361,7 @@ def test_downgrade(self, sfdc_mock, gud_mock):
 class SubHubEventTests(TestCase):
     charge_data = {
         'event_id': 'the-event-id',
-        'event_type': 'customer.source.expiring',
+        'event_type': 'customer.created',
         'customer_id': 'cus_1234',
         'plan_amount': '1000',
         'current_period_end': '1566305505',
@@ -379,15 +378,6 @@ class SubHubEventTests(TestCase):
         'nickname': 'bowling',
     }
 
-    @patch('basket.news.tasks.sfmc')
-    def test_credit_card_expiring(self, sfmc_mock, sfdc_mock, gud_mock):
-        process_subhub_event_credit_card_expiring({
-            'email': 'dude@example.com',
-        })
-
-        sfmc_mock.send_mail.assert_called_with(settings.SUBHUB_CC_EXPIRE_TRIGGER,
-            'dude@example.com', 'dude@example.com')
-
     def test_customer_created_customer_found(self, sfdc_mock, gud_mock):
         """
         Contact found by email only
diff --git a/basket/news/tests/test_views.py b/basket/news/tests/test_views.py
--- a/basket/news/tests/test_views.py
+++ b/basket/news/tests/test_views.py
@@ -1380,7 +1380,6 @@ def setUp(self):
         self.client = Client()
 
         self._patch_views('process_subhub_event_customer_created')
-        self._patch_views('process_subhub_event_credit_card_expiring')
         self._patch_views('process_subhub_event_subscription_charge')
         self._patch_views('process_subhub_event_subscription_cancel')
         self._patch_views('process_subhub_event_payment_failed')
@@ -1390,7 +1389,6 @@ def setUp(self):
         views.SUBHUB_EVENT_TYPES.update({
             'customer.created': self.process_subhub_event_customer_created,
             'customer.recurring_charge': self.process_subhub_event_subscription_charge,
-            'customer.source.expiring': self.process_subhub_event_credit_card_expiring,
             'customer.subscription.created': self.process_subhub_event_subscription_charge,
             'customer.subscription.cancelled': self.process_subhub_event_subscription_cancel,
             'invoice.payment_failed': self.process_subhub_event_payment_failed,
@@ -1423,15 +1421,6 @@ def test_customer_recurring_charge_task(self):
         assert resp.status_code == 200
         self.process_subhub_event_subscription_charge.delay.assert_called_with(data)
 
-    def test_customer_source_expiring_task(self):
-        self.has_valid_api_key.return_value = True
-        data = {'event_type': 'customer.source.expiring'}
-        resp = self.client.post('/subhub/',
-                                data=json.dumps(data),
-                                content_type='application/json')
-        assert resp.status_code == 200
-        self.process_subhub_event_credit_card_expiring.delay.assert_called_with(data)
-
     def test_customer_subscription_created_task(self):
         self.has_valid_api_key.return_value = True
         data = {'event_type': 'customer.subscription.created'}