summaryrefslogtreecommitdiff
path: root/postgresqleu/paypal
diff options
context:
space:
mode:
authorMagnus Hagander2018-12-15 10:05:34 +0000
committerMagnus Hagander2018-12-15 10:05:34 +0000
commitd3cbef33ecc739a7fea78ab21ea097178c204f91 (patch)
treeb56248a4d520e13197491b53eb0b3feec2d0e3b6 /postgresqleu/paypal
parentf01500dcf70022e2d23b91c147a6254ac8c4e3b2 (diff)
Replace usage of has_key()
It has been deprecated, and instead we should use "in" and "not in", so make that change across the board.
Diffstat (limited to 'postgresqleu/paypal')
-rw-r--r--postgresqleu/paypal/management/commands/paypal_fetch.py8
-rwxr-xr-xpostgresqleu/paypal/management/commands/paypal_match.py2
-rw-r--r--postgresqleu/paypal/util.py3
-rw-r--r--postgresqleu/paypal/views.py6
4 files changed, 10 insertions, 9 deletions
diff --git a/postgresqleu/paypal/management/commands/paypal_fetch.py b/postgresqleu/paypal/management/commands/paypal_fetch.py
index ae7d0b50..54d843f7 100644
--- a/postgresqleu/paypal/management/commands/paypal_fetch.py
+++ b/postgresqleu/paypal/management/commands/paypal_fetch.py
@@ -53,14 +53,14 @@ class PaypalBaseTransaction(object):
elif r['TRANSACTIONTYPE'][0] == 'sendmoney':
# This is sending of money, and not receiving. The transaction
# text (naturally) goes in a completely different field.
- if r.has_key('NOTE'):
+ if 'NOTE' in r:
self.transinfo.transtext = 'Paypal payment: %s' % r['NOTE'][0]
else:
self.transinfo.transtext = 'Paypal payment with empty note'
else:
- if r.has_key('SUBJECT'):
+ if 'SUBJECT' in r:
self.transinfo.transtext = r['SUBJECT'][0]
- elif r.has_key('L_NAME0'):
+ elif 'L_NAME0' in r:
self.transinfo.transtext = r['L_NAME0'][0]
else:
self.transinfo.transtext = ""
@@ -100,7 +100,7 @@ class PaypalTransfer(PaypalBaseTransaction):
self.transinfo.transtext = "Transfer from Paypal to bank"
self.transinfo.fee = 0
self.transinfo.sender = 'treasurer@postgresql.eu'
- if apistruct.has_key('CURRENCYCODE') and apistruct['CURRENCYCODE'] != settings.CURRENCY_ISO:
+ if apistruct.get('CURRENCYCODE', None) != settings.CURRENCY_ISO:
self.message = "Invalid currency %s" % apistruct['CURRENCYCODE']
self.transinfo.transtext += ' (currency %s, manually adjust amount!)' % apistruct['CURRENCYCODE']
self.transinfo.amount = -1 # To be on the safe side
diff --git a/postgresqleu/paypal/management/commands/paypal_match.py b/postgresqleu/paypal/management/commands/paypal_match.py
index 21606037..e52d4d2d 100755
--- a/postgresqleu/paypal/management/commands/paypal_match.py
+++ b/postgresqleu/paypal/management/commands/paypal_match.py
@@ -102,7 +102,7 @@ class Command(BaseCommand):
accrows = [
(settings.ACCOUNTING_PAYPAL_INCOME_ACCOUNT, trans.transtext[:200], trans.amount - trans.fee, None),
]
- if trans.fee <> 0:
+ if trans.fee != 0:
accrows.append((settings.ACCOUNTING_PAYPAL_FEE_ACCOUNT, trans.transtext[:200], trans.fee, None),)
create_accounting_entry(trans.timestamp.date(), accrows, True, urls)
continue
diff --git a/postgresqleu/paypal/util.py b/postgresqleu/paypal/util.py
index aeb501a9..7c7b42bb 100644
--- a/postgresqleu/paypal/util.py
+++ b/postgresqleu/paypal/util.py
@@ -38,7 +38,8 @@ class PaypalAPI(object):
'STATUS': 'Success',
})
for i in itertools.count(0):
- if not r.has_key('L_TRANSACTIONID{0}'.format(i)):
+ k = 'L_TRANSACTIONID{0}'.format(i)
+ if k not in r:
if i == 0:
# Special case as it seems inconsistent if it starts on 0 or on 1.
# So if there is no 0, just retry the loop at 1, and if there is still
diff --git a/postgresqleu/paypal/views.py b/postgresqleu/paypal/views.py
index c4935e4b..50fa4734 100644
--- a/postgresqleu/paypal/views.py
+++ b/postgresqleu/paypal/views.py
@@ -36,7 +36,7 @@ def paypal_return_handler(request):
# Now for the main handler
# Handle a paypal PDT return
- if not request.GET.has_key('tx'):
+ if 'tx' not in request.GET:
return paypal_error('Transaction id not received from paypal')
tx = request.GET['tx']
@@ -95,7 +95,7 @@ def paypal_return_handler(request):
return paypal_error('Mandatory field %s is missing from paypal data!', k)
# Now let's find the state of the payment
- if not d.has_key('payment_status'):
+ if 'payment_status' not in d:
return paypal_error('Payment status not received from paypal!')
if d['payment_status'] == 'Completed':
@@ -111,7 +111,7 @@ def paypal_return_handler(request):
# Paypal seems to randomly change which field actually contains
# the transaction title.
- if d.has_key('transaction_subject') and d['transaction_subject'] != '':
+ if d.get('transaction_subject', ''):
transtext = d['transaction_subject']
else:
transtext = d['item_name']