From e53e7d84637b25866571521c2c37f2cda6681870 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:18:28 -0700 Subject: [PATCH 01/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/src/namex_pay/version.py | 2 +- services/namex-pay/src/namex_pay/worker.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/services/namex-pay/src/namex_pay/version.py b/services/namex-pay/src/namex_pay/version.py index 15383e486..5a223e27d 100644 --- a/services/namex-pay/src/namex_pay/version.py +++ b/services/namex-pay/src/namex_pay/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '0.1.3' # pylint: disable=invalid-name +__version__ = '0.1.4' # pylint: disable=invalid-name diff --git a/services/namex-pay/src/namex_pay/worker.py b/services/namex-pay/src/namex_pay/worker.py index 8be5c428a..a35545f0d 100644 --- a/services/namex-pay/src/namex_pay/worker.py +++ b/services/namex-pay/src/namex_pay/worker.py @@ -209,8 +209,14 @@ async def process_payment(pay_msg: dict, flask_app: Flask): logger.debug('COMPLETED transaction on queue: %s', pay_msg) if payment_token := pay_msg.get('paymentToken', {}).get('id'): - if payment := Payment.find_by_payment_token(payment_token): - + payment = None + counter = 1 + while not payment and counter <= 5: + payment = Payment.find_by_payment_token(payment_token) + counter += 1 + if not payment: + await asyncio.sleep(0.2) + if payment: if update_payment := await update_payment_record(payment): payment = update_payment # record event From 7abcb934924c5a9dc1c7b92e25de6b8a1c626d82 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:28:21 -0700 Subject: [PATCH 02/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index f2e0e7f14..e4c92c4ed 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -9,7 +9,7 @@ pycountry==20.7.3 Werkzeug==1.0.1 nest_asyncio aiohttp>=3.8.1 -attrs==20.3.0 +attrs>=20.3.0 certifi==2020.12.5 click==7.1.2 Jinja2==2.11.3 From 25faad964bf962c76b4bb306c734363380cf9652 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:35:00 -0700 Subject: [PATCH 03/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index e4c92c4ed..678c1730a 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -16,7 +16,7 @@ Jinja2==2.11.3 MarkupSafe==1.1.1 pyrsistent==0.17.3 six==1.15.0 -urllib3==1.26.4 +urllib3>=1.26.4 requests==2.25.1 protobuf==3.20.1 From 11a627acdcf5e0a00a5f96a0c3f8def112e0f339 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:47:23 -0700 Subject: [PATCH 04/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index 678c1730a..75f6aa9bc 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -10,7 +10,7 @@ Werkzeug==1.0.1 nest_asyncio aiohttp>=3.8.1 attrs>=20.3.0 -certifi==2020.12.5 +certifi>=2022.9.24 click==7.1.2 Jinja2==2.11.3 MarkupSafe==1.1.1 From 2882238df3ac7119e738d1b5ce1bb4f1db74e264 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:52:04 -0700 Subject: [PATCH 05/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index 75f6aa9bc..e281179b5 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -11,7 +11,7 @@ nest_asyncio aiohttp>=3.8.1 attrs>=20.3.0 certifi>=2022.9.24 -click==7.1.2 +click>=8.1.3 Jinja2==2.11.3 MarkupSafe==1.1.1 pyrsistent==0.17.3 From a83b573d7df2a15a6c4069092683d884fe67664c Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:57:17 -0700 Subject: [PATCH 06/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index e281179b5..df53aae4a 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -19,6 +19,7 @@ six==1.15.0 urllib3>=1.26.4 requests==2.25.1 protobuf==3.20.1 +idna>=2.5 git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas git+https://github.com/bcgov/namex.git#egg=namex&subdirectory=api From df71b6b363734cd90b832887a9df45691834982c Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 09:51:40 -0700 Subject: [PATCH 07/19] update requirement.txt in order to pass build --- services/namex-pay/requirements.txt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index df53aae4a..fca611b46 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -1,25 +1,9 @@ Flask==1.1.2 itsdangerous==1.1.0 -jsonschema==3.2.0 -python-dotenv==0.17.1 sentry-sdk[flask] asyncio-nats-client==0.11.4 asyncio-nats-streaming==0.4.0 -pycountry==20.7.3 -Werkzeug==1.0.1 -nest_asyncio -aiohttp>=3.8.1 -attrs>=20.3.0 -certifi>=2022.9.24 -click>=8.1.3 -Jinja2==2.11.3 -MarkupSafe==1.1.1 -pyrsistent==0.17.3 -six==1.15.0 -urllib3>=1.26.4 -requests==2.25.1 -protobuf==3.20.1 -idna>=2.5 +requests>=2.25.1 git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas git+https://github.com/bcgov/namex.git#egg=namex&subdirectory=api From 5b16c9fc118d2422d956e86e7680f0b2209261ef Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:18:28 -0700 Subject: [PATCH 08/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/src/namex_pay/version.py | 2 +- services/namex-pay/src/namex_pay/worker.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/services/namex-pay/src/namex_pay/version.py b/services/namex-pay/src/namex_pay/version.py index 15383e486..5a223e27d 100644 --- a/services/namex-pay/src/namex_pay/version.py +++ b/services/namex-pay/src/namex_pay/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '0.1.3' # pylint: disable=invalid-name +__version__ = '0.1.4' # pylint: disable=invalid-name diff --git a/services/namex-pay/src/namex_pay/worker.py b/services/namex-pay/src/namex_pay/worker.py index 8be5c428a..a35545f0d 100644 --- a/services/namex-pay/src/namex_pay/worker.py +++ b/services/namex-pay/src/namex_pay/worker.py @@ -209,8 +209,14 @@ async def process_payment(pay_msg: dict, flask_app: Flask): logger.debug('COMPLETED transaction on queue: %s', pay_msg) if payment_token := pay_msg.get('paymentToken', {}).get('id'): - if payment := Payment.find_by_payment_token(payment_token): - + payment = None + counter = 1 + while not payment and counter <= 5: + payment = Payment.find_by_payment_token(payment_token) + counter += 1 + if not payment: + await asyncio.sleep(0.2) + if payment: if update_payment := await update_payment_record(payment): payment = update_payment # record event From c3dc8e23b2089955b21f8ce80e9d203351e970f9 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:28:21 -0700 Subject: [PATCH 09/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index f2e0e7f14..e4c92c4ed 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -9,7 +9,7 @@ pycountry==20.7.3 Werkzeug==1.0.1 nest_asyncio aiohttp>=3.8.1 -attrs==20.3.0 +attrs>=20.3.0 certifi==2020.12.5 click==7.1.2 Jinja2==2.11.3 From 2d5c7c3d7eb133a9429214d151578b4f0966b94a Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:35:00 -0700 Subject: [PATCH 10/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index e4c92c4ed..678c1730a 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -16,7 +16,7 @@ Jinja2==2.11.3 MarkupSafe==1.1.1 pyrsistent==0.17.3 six==1.15.0 -urllib3==1.26.4 +urllib3>=1.26.4 requests==2.25.1 protobuf==3.20.1 From 9f72d8e7460a314a3a0ab5a791c9b0ee364bdd86 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:47:23 -0700 Subject: [PATCH 11/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index 678c1730a..75f6aa9bc 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -10,7 +10,7 @@ Werkzeug==1.0.1 nest_asyncio aiohttp>=3.8.1 attrs>=20.3.0 -certifi==2020.12.5 +certifi>=2022.9.24 click==7.1.2 Jinja2==2.11.3 MarkupSafe==1.1.1 From e8af8761dfb647480e00f21fe59471f0d63cf3e2 Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:52:04 -0700 Subject: [PATCH 12/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index 75f6aa9bc..e281179b5 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -11,7 +11,7 @@ nest_asyncio aiohttp>=3.8.1 attrs>=20.3.0 certifi>=2022.9.24 -click==7.1.2 +click>=8.1.3 Jinja2==2.11.3 MarkupSafe==1.1.1 pyrsistent==0.17.3 From d65030fd3aad811ae80a16fd3fc5970278671c7d Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 08:57:17 -0700 Subject: [PATCH 13/19] allow to delay at most 1 sec when retrieving payment unsuccessful in payment queue call back --- services/namex-pay/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index e281179b5..df53aae4a 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -19,6 +19,7 @@ six==1.15.0 urllib3>=1.26.4 requests==2.25.1 protobuf==3.20.1 +idna>=2.5 git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas git+https://github.com/bcgov/namex.git#egg=namex&subdirectory=api From ceb84bcb55c05b47f3bb7209b3d691f30448898c Mon Sep 17 00:00:00 2001 From: eve-git Date: Thu, 14 Sep 2023 09:51:40 -0700 Subject: [PATCH 14/19] update requirement.txt in order to pass build --- services/namex-pay/requirements.txt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index df53aae4a..fca611b46 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -1,25 +1,9 @@ Flask==1.1.2 itsdangerous==1.1.0 -jsonschema==3.2.0 -python-dotenv==0.17.1 sentry-sdk[flask] asyncio-nats-client==0.11.4 asyncio-nats-streaming==0.4.0 -pycountry==20.7.3 -Werkzeug==1.0.1 -nest_asyncio -aiohttp>=3.8.1 -attrs>=20.3.0 -certifi>=2022.9.24 -click>=8.1.3 -Jinja2==2.11.3 -MarkupSafe==1.1.1 -pyrsistent==0.17.3 -six==1.15.0 -urllib3>=1.26.4 -requests==2.25.1 -protobuf==3.20.1 -idna>=2.5 +requests>=2.25.1 git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas git+https://github.com/bcgov/namex.git#egg=namex&subdirectory=api From 2b10ee8581bccc0aefe74f0e26660d04f2ecfe2a Mon Sep 17 00:00:00 2001 From: eve-git Date: Fri, 15 Sep 2023 13:10:32 -0700 Subject: [PATCH 15/19] update requirements.txt --- api/requirements.txt | 2 +- services/namex-pay/requirements.txt | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/api/requirements.txt b/api/requirements.txt index f1e4af487..4d78600e8 100755 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -13,7 +13,7 @@ alembic==1.5.8 aniso8601==9.0.1 asyncio-nats-client==0.11.4 asyncio-nats-streaming==0.4.0 -attrs==22.1.0 +attrs==22.2.0 blinker==1.5 cachelib==0.9.0 certifi==2022.9.24 diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index fca611b46..f2e0e7f14 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -1,9 +1,24 @@ Flask==1.1.2 itsdangerous==1.1.0 +jsonschema==3.2.0 +python-dotenv==0.17.1 sentry-sdk[flask] asyncio-nats-client==0.11.4 asyncio-nats-streaming==0.4.0 -requests>=2.25.1 +pycountry==20.7.3 +Werkzeug==1.0.1 +nest_asyncio +aiohttp>=3.8.1 +attrs==20.3.0 +certifi==2020.12.5 +click==7.1.2 +Jinja2==2.11.3 +MarkupSafe==1.1.1 +pyrsistent==0.17.3 +six==1.15.0 +urllib3==1.26.4 +requests==2.25.1 +protobuf==3.20.1 git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas git+https://github.com/bcgov/namex.git#egg=namex&subdirectory=api From df41efb3da37af6966347cd72efe4072e950976f Mon Sep 17 00:00:00 2001 From: eve-git Date: Fri, 15 Sep 2023 13:23:24 -0700 Subject: [PATCH 16/19] update requirements --- services/namex-pay/requirements.txt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index fca611b46..125562625 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -1,9 +1,29 @@ Flask==1.1.2 itsdangerous==1.1.0 -sentry-sdk[flask] +jsonschema==4.16.0 +python-dotenv==0.21.0 +sentry-sdk[flask]==1.20.0 asyncio-nats-client==0.11.4 asyncio-nats-streaming==0.4.0 -requests>=2.25.1 +pycountry==22.3.5 +Werkzeug==1.0.1 +nest_asyncio +aiohttp>=3.8.1 +attrs==22.2.0 +certifi==2022.9.24 +click==8.1.3 +Jinja2==2.11.3 +MarkupSafe==1.1.1 +pyrsistent==0.18.1 +six==1.16.0 +urllib3==1.26.12 +requests==2.28.1 +protobuf==3.20.1 +blinker==1.5 +charset-normalizer==2.1.1 +idna==3.4 +importlib-resources==5.10.0 +zipp==3.8.1 git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas git+https://github.com/bcgov/namex.git#egg=namex&subdirectory=api From ce66a322e0b51a8f6ef90b4e3c60a98ce2080ca6 Mon Sep 17 00:00:00 2001 From: eve-git Date: Fri, 15 Sep 2023 13:29:32 -0700 Subject: [PATCH 17/19] update requirements --- services/namex-pay/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/namex-pay/requirements.txt b/services/namex-pay/requirements.txt index 125562625..3a0d37836 100755 --- a/services/namex-pay/requirements.txt +++ b/services/namex-pay/requirements.txt @@ -9,7 +9,7 @@ pycountry==22.3.5 Werkzeug==1.0.1 nest_asyncio aiohttp>=3.8.1 -attrs==22.2.0 +attrs==22.1.0 certifi==2022.9.24 click==8.1.3 Jinja2==2.11.3 From 25bf1fcac8fe354c7004b721201c1f63b829e28f Mon Sep 17 00:00:00 2001 From: eve-git Date: Fri, 15 Sep 2023 14:12:39 -0700 Subject: [PATCH 18/19] correct the unexpected change --- api/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/requirements.txt b/api/requirements.txt index 4d78600e8..f1e4af487 100755 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -13,7 +13,7 @@ alembic==1.5.8 aniso8601==9.0.1 asyncio-nats-client==0.11.4 asyncio-nats-streaming==0.4.0 -attrs==22.2.0 +attrs==22.1.0 blinker==1.5 cachelib==0.9.0 certifi==2022.9.24 From d23cee38c538966cd7128c0785fa49ff0807a1f0 Mon Sep 17 00:00:00 2001 From: eve-git Date: Wed, 20 Sep 2023 10:18:50 -0700 Subject: [PATCH 19/19] raise exception if the payment record cannot be found. --- services/namex-pay/src/namex_pay/worker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/services/namex-pay/src/namex_pay/worker.py b/services/namex-pay/src/namex_pay/worker.py index a35545f0d..eecc25b3d 100644 --- a/services/namex-pay/src/namex_pay/worker.py +++ b/services/namex-pay/src/namex_pay/worker.py @@ -258,6 +258,7 @@ async def process_payment(pay_msg: dict, flask_app: Flask): else: logger.debug('Queue Error: Unable to find payment record for :%s', pay_msg) capture_message(f'Queue Error: Unable to find payment record for :{pay_msg}', level='error') + raise QueueException(f'Queue Error: Unable to find payment record for :{pay_msg}') else: logger.debug('Queue Error: Missing id :%s', pay_msg) capture_message(f'Queue Error: Missing id :{pay_msg}', level='error')