Skip to content

Commit

Permalink
Small prod tweaks - Hide logging for 404 add in declined (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Sep 12, 2024
1 parent ba9eda3 commit ab453c9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions jobs/payment-jobs/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jobs/payment-jobs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions jobs/payment-jobs/tasks/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ class PaymentDetailsGlStatus(Enum):
INPRG = 'INPRG'
RJCT = 'RJCT' # Should have refundglerrormessage
CMPLT = 'CMPLT'
DECLINED = 'DECLINED'
6 changes: 3 additions & 3 deletions jobs/payment-jobs/tasks/direct_pay_automated_refund_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pay-api/src/pay_api/services/oauth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab453c9

Please sign in to comment.