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.
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