Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20088 - Updating unlock_frozen_accounts to take in payment_id and payment_account_id #1563

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pay-api/src/pay_api/services/payment_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
current_local_time, get_local_formatted_date, get_outstanding_txns_from_date, get_str_by_path, mask)

from .flags import flags
from .payment import Payment


class PaymentAccount(): # pylint: disable=too-many-instance-attributes, too-many-public-methods
Expand Down Expand Up @@ -871,9 +870,9 @@ def create_account_event_payload(self, event_type: str, receipt_info: dict = Non
return payload

@staticmethod
def unlock_frozen_accounts(payment: Payment):
def unlock_frozen_accounts(payment_id: int, payment_account_id: int):
"""Unlock frozen accounts."""
pay_account: PaymentAccount = PaymentAccount.find_by_id(payment.payment_account_id)
pay_account: PaymentAccount = PaymentAccount.find_by_id(payment_account_id)
if pay_account.cfs_account_status == CfsAccountStatus.FREEZE.value:
current_app.logger.info(f'Unlocking Frozen Account {pay_account.auth_account_id}')
cfs_account: CfsAccountModel = CfsAccountModel.find_effective_by_account_id(pay_account.id)
Expand All @@ -882,7 +881,7 @@ def unlock_frozen_accounts(payment: Payment):
cfs_account.status = CfsAccountStatus.ACTIVE.value
cfs_account.save()

receipt_info = ReceiptService.get_nsf_receipt_details(payment.id)
receipt_info = ReceiptService.get_nsf_receipt_details(payment_id)
payload = pay_account.create_account_event_payload(
QueueMessageTypes.NSF_UNLOCK_ACCOUNT.value,
receipt_info=receipt_info
Expand Down
3 changes: 2 additions & 1 deletion pay-api/src/pay_api/services/payment_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ def update_transaction(transaction_id: uuid, # pylint: disable=too-many-locals
active_failed_payments = Payment.get_failed_payments(auth_account_id=payment_account.auth_account_id)
current_app.logger.info('active_failed_payments %s', active_failed_payments)
if not active_failed_payments:
PaymentAccount.unlock_frozen_accounts(payment)
PaymentAccount.unlock_frozen_accounts(payment_id=payment.id,
payment_account_id=payment.payment_account_id)

transaction = PaymentTransaction.__wrap_dao(transaction_dao)

Expand Down
Loading