From cb3a900db51b3b1ab16a29c499921b0328c133b8 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 22 Sep 2025 11:35:57 +0200 Subject: [PATCH] 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. --- postgresqleu/paypal/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.39.5