From 3301f578a2e4060a6a8b3addb49fcbea7b08f017 Mon Sep 17 00:00:00 2001 From: Baptiste Delpey Date: Mon, 8 Dec 2014 13:27:31 +0100 Subject: [PATCH] paypal : we now ignore transactions with no 'displayAmount' --- modules/paypal/newpages.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/paypal/newpages.py b/modules/paypal/newpages.py index 9a142681..291bd17c 100644 --- a/modules/paypal/newpages.py +++ b/modules/paypal/newpages.py @@ -91,7 +91,9 @@ class NewPartHistoryPage(Page): for status in ['PENDING', 'COMPLETED']: transac = self.document['data']['activity'][status] for t in transac: - transactions.append(self.parse_transaction(t)) + tran = self.parse_transaction(t) + if tran: + transactions.append(tran) transactions.sort(key=lambda tr: tr.rdate, reverse=True) for t in transactions: @@ -105,7 +107,10 @@ class NewPartHistoryPage(Page): except KeyError: raw = transaction['displayType'] t.parse(date=date, raw=raw) - amount = transaction['displayAmount'] + try: + amount = transaction['displayAmount'] + except KeyError: + return t.set_amount(amount) t._currency = transaction['currencyCode'] return t