summaryrefslogtreecommitdiff
path: root/postgresqleu/paypal/util.py
diff options
context:
space:
mode:
authorMagnus Hagander2023-12-04 14:49:47 +0000
committerMagnus Hagander2023-12-04 14:57:20 +0000
commitef7cdabbcc92e5a268a0d5870a420f91d3dc9565 (patch)
treec4a2325dd91f7e30d7cacad0c752a86d2b3e6f7d /postgresqleu/paypal/util.py
parent1e508a1f3e5ebd3e4063918d80cf6086267b1310 (diff)
Fall back to treasurer email in incomplete paypal transactions
Seems paypal sometimes can give back transactions without an email address even if the email address is mandatory. Because why not. When this happens, just fall back to our treasurer email from the config - it's almost guaranteed to be the wrong but but it is also guaranteed to exist, so the treasurer will just have to clean up the records manually in accounting later.
Diffstat (limited to 'postgresqleu/paypal/util.py')
-rw-r--r--postgresqleu/paypal/util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/postgresqleu/paypal/util.py b/postgresqleu/paypal/util.py
index 76b04f08..452a0ea5 100644
--- a/postgresqleu/paypal/util.py
+++ b/postgresqleu/paypal/util.py
@@ -138,7 +138,10 @@ class PaypalAPI(object):
r['EMAIL'] = t['payer_info'].get('email_address', self.pm.config('email'))
if not r['EMAIL']:
- r['EMAIL'] = t['payer_info']['email_address']
+ # Seems with some type of transfers things can show up with non-existent
+ # email addresses which shouldn't happen. We'll just have to fall back to our
+ # own which we know is wrong, but we also know it exists-
+ r['EMAIL'] = t['payer_info'].get('email_address', self.pm.config('email'))
# Figure out the name, since it can be in completely different places
# depending on the transaction (even for the same type of transactions)