diff --git a/app/integrations/kafka.py b/app/integrations/kafka.py index 75d89ef..23b333c 100644 --- a/app/integrations/kafka.py +++ b/app/integrations/kafka.py @@ -127,10 +127,15 @@ class KafkaIntegration: logger.info(f"Calling disbursement service with message: {message}") try: - response = SimbrellaClient.disbursement(message) + response = SimbrellaClient.disburse_loan(message) logger.info( f"Successfully sent message to disbursement service: {response}" ) + + # LoanService.set_disbursement_date(loan_id=loan_data['debtId'], + # customer_id=customerId) # must mark it on way out + # + except Exception as e: logger.info(f"Failed to call disbursement service: {e}") #raise diff --git a/app/integrations/simbrella.py b/app/integrations/simbrella.py index 3a3b650..68b33eb 100644 --- a/app/integrations/simbrella.py +++ b/app/integrations/simbrella.py @@ -15,9 +15,9 @@ class SimbrellaClient: BANK_CALL_BASE_URL = settings.BANK_CALL_BASE_URL @staticmethod - def disbursement(data): - api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/Disbursement" - logger.info(f"Calling Disbursement endpoint with data: {data}") + def disburse_loan(data): + api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/DisburseLoan" + logger.info(f"Calling DisburseLoan endpoint with data: {data}") # Check if the transaction exists logger.info(f"Checking if transaction exists") @@ -50,7 +50,6 @@ class SimbrellaClient: interest_fee = loan_charges.get("INTEREST")['amount'] insurance_fee = loan_charges.get("INSURANCE")['amount'] - disbursement_data ={ "requestId": data['requestId'], "transactionId": data['transactionId'], @@ -73,17 +72,12 @@ class SimbrellaClient: logger.info(f"Disbursement response: {response.json()}") - - - - - - except Exception as e: logger.info(f"Failed to call Disbursement endpoint: {e}") return 0 return 1 +#Calling CollectLoan endpoint with data: {'transactionId': 'TRX1747960765928545', 'customerId': 'CID0000055362', 'productId': '101', 'debtId': '9590'} @staticmethod def collect_loan(data): @@ -101,7 +95,7 @@ class SimbrellaClient: return 0 collect_loan_data = { - "transactionId": "T002", + "transactionId": data['transactionId'], "fbnTransactionId": "FBN20231123", "debtId": data['debtId'], "customerId": data['customerId'], @@ -109,12 +103,29 @@ class SimbrellaClient: "productId": data['productId'], "collectAmount": 80000, "penalCharge": 0, + "channel": "USSD", "collectionMethod": 1, "lienAmount": 80000, "countryId": "01", "comment": "Testing CollectionLoanRequest" } + # { + # "channel": "string", + # "transactionId": "string", + # "fbnTransactionId": "string", + # "debtId": "string", + # "accountId": "string", + # "customerId": "string", + # "productId": "string", + # "collectAmount": 0, + # "penalCharge": 0, + # "collectionMethod": "string", + # "lienAmount": 0, + # "countryId": "string", + # "comment": "string" + # } + try: logger.info(f"Here is your CollectLoan Request data ***** : {collect_loan_data}") response = requests.post(api_url, json=collect_loan_data, headers=get_headers())