adyen-examples / checkoutCreate

An external tool which allows you to build a drop-in integration and make customizations as outlined in the Adyen style sheet.
MIT License
5 stars 6 forks source link

Error when running any type of payment for my account #60

Closed jlengrand closed 1 year ago

jlengrand commented 1 year ago

When trying to use my account, I'm getting the following error whatever method of payment I'm using:

'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
2022-11-04 13:54:05,659 - INFO - Running on http://localhost:8080
'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.
request_data:
{'countryCode': 'NL', 'currency': 'EUR', 'locale': 'en_NL', 'city': 'Amsterdam', 'postalCode': '1011DJ', 'street': 'Simon Carmiggeltstraat', 'houseNumberOrName': '6 - 50', 'blockedPaymentMethods': []}
/paymentMethods request:
{'reference': 'Reference 7b0ec906-5af2-4b9d-a793-a94b284ff3d5', 'countryCode': 'NL', 'shopperReference': 'UniqueReference', 'channel': 'Web', 'merchantAccount': 'LengrandECOM', 'blockedPaymentMethods': []}
/paymentMethods response:
{"paymentMethods": [{"issuers": [{"id": "1121", "name": "Test Issuer"}, {"id": "1154", "name": "Test Issuer 5"}, {"id": "1153", "name": "Test Issuer 4"}, {"id": "1152", "name": "Test Issuer 3"}, {"id": "1163", "name": "Ideal bridge test issuer"}, {"id": "1151", "name": "Test Issuer 2"}, {"id": "1162", "name": "Test Issuer Cancelled"}, {"id": "1161", "name": "Test Issuer Pending"}, {"id": "1160", "name": "Test Issuer Refused"}, {"id": "1159", "name": "Test Issuer 10"}, {"id": "1158", "name": "Test Issuer 9"}, {"id": "1157", "name": "Test Issuer 8"}, {"id": "1156", "name": "Test Issuer 7"}, {"id": "1155", "name": "Test Issuer 6"}], "name": "iDEAL", "type": "ideal"}, {"brands": ["mc", "visa", "amex", "diners", "jcb"], "name": "Credit Card", "type": "scheme"}, {"name": "Pay later with Klarna.", "type": "klarna"}, {"name": "Paysafecard", "type": "paysafecard"}, {"name": "Pay over time with Klarna.", "type": "klarna_account"}, {"name": "Pay now with Klarna.", "type": "klarna_paynow"}]}
Traceback (most recent call last):
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/venv/lib/python3.9/site-packages/flask/app.py", line 2548, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/venv/lib/python3.9/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/venv/lib/python3.9/site-packages/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/venv/lib/python3.9/site-packages/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/venv/lib/python3.9/site-packages/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/venv/lib/python3.9/site-packages/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/app/app.py", line 42, in initiate_payment
    return adyen_payments(request, locale_data)
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/app/main/payments.py", line 106, in adyen_payments
    sanatizeRequest(payments_request)
  File "/Users/julienlengrand-lambert/Developer/adyen/checkoutCreate/app/main/payments.py", line 143, in sanatizeRequest
    del payments_request['stateOrProvince']
KeyError: 'stateOrProvince'

Trying to dig into the issue

anamotaadyen commented 1 year ago

This should be fixed already in https://github.com/adyen-examples/checkoutCreate/pull/49 Do you have the latest version?

jlengrand commented 1 year ago

Yup, I just pulled main a minute ago to create a new branch.

I run from main, that should be enough right?

On Fri, Nov 4, 2022 at 2:02 PM anamotaadyen @.***> wrote:

This should be fixed already in #49 https://github.com/adyen-examples/checkoutCreate/pull/49 Do you have the latest version?

— Reply to this email directly, view it on GitHub https://github.com/adyen-examples/checkoutCreate/issues/60#issuecomment-1303503398, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHBAQUKC7VEYGRXOWOVAT3WGUCONANCNFSM6AAAAAARXE4VTU . You are receiving this because you authored the thread.Message ID: @.***>

--

Julien Lengrand-Lambert Twitter : @jl https://twitter.com/jlengrandengrand https://twitter.com/jlengrand Mobile : +31680067605 Email: @.*** http://lengrand.fr

jlengrand commented 1 year ago

well actually I believe that issue is the origin of the problem

    del payments_request['stateOrProvince']

leads to a KeyError :).

anamotaadyen commented 1 year ago

Correct, I see the issue, this is needed for US, but I think we need to now add the field by default to then sanitise, for other countries

jlengrand commented 1 year ago

Here is a potential fix to avoid KeyErrors :

https://github.com/adyen-examples/checkoutCreate/pull/61

jlengrand commented 1 year ago

(with some typo fixes as a bonus 😊)