done with check transaction_id on repayment

This commit was merged in pull request #14.
This commit is contained in:
2025-04-16 10:38:39 +01:00
parent a8f32fdf68
commit e75a025dab
5 changed files with 50 additions and 8 deletions
+2 -2
View File
@@ -131,7 +131,7 @@ class KafkaIntegration:
try:
response = SimbrellaClient.disbursement(message)
logger.info(
f"Successfully sent message to disbursement service: {response.status_code}"
f"Successfully sent message to disbursement service: {response}"
)
except Exception as e:
logger.info(f"Failed to call disbursement service: {e}")
@@ -145,7 +145,7 @@ class KafkaIntegration:
try:
response = SimbrellaClient.collect_loan(message)
logger.info(
f"Successfully sent message to collect_loan service: {response.status_code}"
f"Successfully sent message to collect_loan service: {response}"
)
except Exception as e:
logger.info(f"Failed to call collect_loan service: {e}")
+12 -5
View File
@@ -4,6 +4,7 @@ from app.utils.auth import get_headers
from app.utils.logger import logger
from flask import jsonify, current_app
from app.services.transactions import TransactionService
from app.services.repayment import RepaymentService
class SimbrellaClient:
@@ -58,6 +59,16 @@ class SimbrellaClient:
api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/CollectLoan"
logger.info(f"Calling CollectLoan endpoint with data: {data}")
# Check if the repayment exists
logger.info(f"Checking if repayment exists")
repayment = RepaymentService.get_repayment_by_transaction_id(transaction_id=data['transactionId'])
logger.info(f"Response from database: {repayment}")
# If repayment is not found
if not repayment:
logger.info(f"Repayment id: {data['transactionId']}, was not found")
return 0
collect_loan_data = {
"transactionId": "T002",
"fbnTransactionId": "FBN20231123",
@@ -119,8 +130,4 @@ class SimbrellaClient:
except Exception as e:
logger.info(f"Failed to call Payment Callback endpoint: {e}")
raise
@staticmethod
def check_transaction(txn_id):
return run_in_app_context(Transaction.get_transaction_by_id(txn_id))
raise