diff --git a/jobs/payment-jobs/poetry.lock b/jobs/payment-jobs/poetry.lock index fd80d2a25..6d6df18e8 100644 --- a/jobs/payment-jobs/poetry.lock +++ b/jobs/payment-jobs/poetry.lock @@ -2021,9 +2021,9 @@ werkzeug = "3.0.3" [package.source] type = "git" -url = "https://github.com/bcgov/sbc-pay.git" -reference = "main" -resolved_reference = "019d6fdf3a32425c6aa3b7bfefa68605975ca8e9" +url = "https://github.com/seeker25/sbc-pay.git" +reference = "prod_fixes" +resolved_reference = "50806293b8446d1c6ab74142024d64656968a3bb" subdirectory = "pay-api" [[package]] @@ -3174,4 +3174,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "8a527406826dfa42864635c2cf7af865d99560735709930d164c912607e83557" +content-hash = "6d5a2f1160278623a68e6ed9e8455f689da5609b9b2b43047962546f5dc9df20" diff --git a/jobs/payment-jobs/pyproject.toml b/jobs/payment-jobs/pyproject.toml index 2eb73e105..5bd1368bd 100644 --- a/jobs/payment-jobs/pyproject.toml +++ b/jobs/payment-jobs/pyproject.toml @@ -7,7 +7,7 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.12" -pay-api = {git = "https://github.com/bcgov/sbc-pay.git", branch = "main", subdirectory = "pay-api"} +pay-api = {git = "https://github.com/seeker25/sbc-pay.git", branch = "prod_fixes", subdirectory = "pay-api"} flask = "^3.0.2" flask-sqlalchemy = "^3.1.1" sqlalchemy = "^2.0.28" diff --git a/jobs/payment-jobs/tasks/common/enums.py b/jobs/payment-jobs/tasks/common/enums.py index 7861b409b..ba6157840 100644 --- a/jobs/payment-jobs/tasks/common/enums.py +++ b/jobs/payment-jobs/tasks/common/enums.py @@ -22,3 +22,4 @@ class PaymentDetailsGlStatus(Enum): INPRG = 'INPRG' RJCT = 'RJCT' # Should have refundglerrormessage CMPLT = 'CMPLT' + DECLINED = 'DECLINED' diff --git a/jobs/payment-jobs/tasks/direct_pay_automated_refund_task.py b/jobs/payment-jobs/tasks/direct_pay_automated_refund_task.py index 87a84140b..755f97b70 100644 --- a/jobs/payment-jobs/tasks/direct_pay_automated_refund_task.py +++ b/jobs/payment-jobs/tasks/direct_pay_automated_refund_task.py @@ -77,7 +77,7 @@ def handle_non_complete_credit_card_refunds(cls): # Cron is setup to run between 6 to 8 UTC. Feedback is updated after 11pm. current_app.logger.debug(f'Processing invoice: {invoice.id} - created on: {invoice.created_on}') status = OrderStatus.from_dict(cls._query_order_status(invoice)) - if cls._is_glstatus_rejected(status): + if cls._is_glstatus_rejected_or_declined(status): cls._refund_error(status, invoice) elif cls._is_status_paid_and_invoice_refund_requested(status, invoice): cls._refund_paid(invoice) @@ -134,9 +134,9 @@ def _refund_complete(cls, invoice: Invoice): refund.save() @staticmethod - def _is_glstatus_rejected(status: OrderStatus) -> bool: + def _is_glstatus_rejected_or_declined(status: OrderStatus) -> bool: """Check for bad refundglstatus.""" - return any(refund_data.refundglstatus == PaymentDetailsGlStatus.RJCT + return any(refund_data.refundglstatus in [PaymentDetailsGlStatus.RJCT, PaymentDetailsGlStatus.DECLINED] for line in status.revenue for refund_data in line.refund_data) @staticmethod diff --git a/pay-api/src/pay_api/services/oauth_service.py b/pay-api/src/pay_api/services/oauth_service.py index 44ff4d4b5..85b236f91 100644 --- a/pay-api/src/pay_api/services/oauth_service.py +++ b/pay-api/src/pay_api/services/oauth_service.py @@ -73,8 +73,9 @@ def post(endpoint, token, auth_header_type: AuthHeaderType, # pylint: disable=t current_app.logger.error(exc) raise ServiceUnavailableException(exc) from exc except HTTPError as exc: - current_app.logger.error( - f"HTTPError on POST with status code {response.status_code if response else ''}") + if not response or response.status_code != 404: + current_app.logger.error( + f"HTTPError on POST with status code {response.status_code if response else ''}") if response and response.status_code >= 500: raise ServiceUnavailableException(exc) from exc raise exc