From: Magnus Hagander Date: Mon, 22 Sep 2025 09:35:57 +0000 (+0200) Subject: Allow for non-existing paypal transaction details key X-Git-Url: http://git.postgresql.org/gitweb/connections.php?a=commitdiff_plain;h=cb3a900db51b3b1ab16a29c499921b0328c133b8;p=pgeu-system.git Allow for non-existing paypal transaction details key Contrary to their own documentation, Paypal now returns a json object with no 'transaction_details' key when there are no matching transactions (previously and per documentation they should return an empty array). To work around this, treat the case of missing key the same as an empty array. --- diff --git a/postgresqleu/paypal/util.py b/postgresqleu/paypal/util.py index 097d812c..2a11379c 100644 --- a/postgresqleu/paypal/util.py +++ b/postgresqleu/paypal/util.py @@ -71,7 +71,7 @@ class PaypalAPI(object): if r.status_code != 200: raise Exception("Failed to get transactions: %s" % r.json()['message']) - for t in r.json()['transaction_details']: + for t in r.json().get('transaction_details', []): if t['transaction_info']['transaction_status'] != 'S': continue