Ejegg has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/370520 )
Change subject: PayPal audit: check for existing recurring donations
......................................................................
PayPal audit: check for existing recurring donations
Bug: T172723
Change-Id: I1009e554581a972251675701a3896d256f6d33f3
---
M audit/paypal/TrrFile.py
M audit/paypal/tests/test_trr_file.py
2 files changed, 23 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/tools
refs/changes/20/370520/1
diff --git a/audit/paypal/TrrFile.py b/audit/paypal/TrrFile.py
index 2b1e851..54b64e9 100644
--- a/audit/paypal/TrrFile.py
+++ b/audit/paypal/TrrFile.py
@@ -187,9 +187,10 @@
log.info("-Unknown\t{id}\t{date}\t(Type
{type})".format(id=out['gateway_txn_id'], date=out['date'], type=event_type))
return
- if queue == 'donations' and
self.crm.transaction_exists(gateway_txn_id=out['gateway_txn_id'],
gateway=out['gateway']):
-
log.info("-Duplicate\t{id}\t{date}\t{type}".format(id=out['gateway_txn_id'],
date=row['Transaction Initiation Date'], type=queue))
- return
+ if queue == 'donations' or queue == 'recurring':
+ if
self.crm.transaction_exists(gateway_txn_id=out['gateway_txn_id'],
gateway=out['gateway']):
+
log.info("-Duplicate\t{id}\t{date}\t{type}".format(id=out['gateway_txn_id'],
date=row['Transaction Initiation Date'], type=queue))
+ return
if queue == 'refund' and
self.crm.transaction_refunded(gateway_txn_id=out['gateway_parent_id'],
gateway=out['gateway']):
log.info("-Duplicate\t{id}\t{date}\t{type}".format(id=out['gateway_txn_id'],
date=row['Transaction Initiation Date'], type=queue))
diff --git a/audit/paypal/tests/test_trr_file.py
b/audit/paypal/tests/test_trr_file.py
index 9b15ca8..35155d0 100644
--- a/audit/paypal/tests/test_trr_file.py
+++ b/audit/paypal/tests/test_trr_file.py
@@ -281,3 +281,22 @@
expected = {'last_name': 'Man', 'txn_type': 'subscr_payment',
'thankyou_date': 0, 'city': '', 'payment_method': '', 'gateway_status': 'S',
'currency': 'USD', 'postal_code': '', 'date': 1474743301, 'subscr_id':
'3GJH3GJ3334214812', 'gateway': 'paypal', 'state_province': '', 'gross': 0.1,
'first_name': 'Banana', 'fee': 0.55, 'gateway_txn_id': 'AS7D98AS7D9A8S7D9AS',
'country': '', 'payment_submethod': '', 'note': '', 'supplemental_address_1':
'', 'settled_date': 1474743301, 'email': '[email protected]',
'street_address': '', 'contribution_tracking_id': '1234567', 'order_id':
'1234567'}
actual = args[0][1]
nose.tools.assert_equals(expected, actual)
+
+
+@patch("queue.redis_wrap.Redis")
+@patch("civicrm.civicrm.Civicrm")
+@patch("process.globals")
+def test_recurring(MockGlobals, MockCivicrm, MockRedis):
+ '''
+ Test that we don't send duplicate recurring messages
+ '''
+ MockCivicrm().transaction_exists.return_value = True
+
+ row = get_recurring_row()
+ parser = audit.paypal.TrrFile.TrrFile("dummy_path")
+
+ parser.parse_line(row)
+
+ # Did we send it?
+ args = MockRedis().send.call_args
+ nose.tools.assert_equals(None, args)
--
To view, visit https://gerrit.wikimedia.org/r/370520
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1009e554581a972251675701a3896d256f6d33f3
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/tools
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits