Skip to content

Commit

Permalink
Merge pull request #61 from adyen-examples/fix/payment-errors
Browse files Browse the repository at this point in the history
Typos and Fixes potential KeyError on key deletion
  • Loading branch information
anamotaadyen authored Nov 4, 2022
2 parents 7c9f58f + 958d5a3 commit 586b7f7
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions app/main/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def adyen_payments(frontend_request, locale_data):
payments_request


sanatizeRequest(payments_request)
sanitizeRequest(payments_request)
print("/payments request:\n" + str(payments_request))

payments_response = adyen.checkout.payments(payments_request)
Expand Down Expand Up @@ -133,16 +133,16 @@ def currency_locale(country):
elif country == "US":
return "USD"

def sanatizeRequest(payments_request):
del payments_request['locale']
del payments_request['currency']
del payments_request['city']
del payments_request['houseNumberOrName']
del payments_request['postalCode']
del payments_request['street']
del payments_request['stateOrProvince']

def sanitizeRequest(payment_request):
safe_delete(payment_request, 'locale')
safe_delete(payment_request, 'currency')

safe_delete(payment_request, 'city')
safe_delete(payment_request, 'currency')
safe_delete(payment_request, 'houseNumberOrName')
safe_delete(payment_request, 'postalCode')
safe_delete(payment_request, 'street')
safe_delete(payment_request, 'stateOrProvince')

# loaded = json.loads(payments_request)
# for item in loaded:
Expand All @@ -165,3 +165,8 @@ def sanatizeRequest(payments_request):
# element.pop('currency', None)
# with open('cleanData.json', 'w') as payments_request:

def safe_delete(payment_request, key):
try:
del payment_request[key]
except KeyError:
print('Error while trying to delete key : ' + key)

0 comments on commit 586b7f7

Please sign in to comment.