Updated the loan service end
This commit is contained in:
@@ -127,10 +127,15 @@ class KafkaIntegration:
|
|||||||
logger.info(f"Calling disbursement service with message: {message}")
|
logger.info(f"Calling disbursement service with message: {message}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = SimbrellaClient.disbursement(message)
|
response = SimbrellaClient.disburse_loan(message)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Successfully sent message to disbursement service: {response}"
|
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:
|
except Exception as e:
|
||||||
logger.info(f"Failed to call disbursement service: {e}")
|
logger.info(f"Failed to call disbursement service: {e}")
|
||||||
#raise
|
#raise
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ class SimbrellaClient:
|
|||||||
BANK_CALL_BASE_URL = settings.BANK_CALL_BASE_URL
|
BANK_CALL_BASE_URL = settings.BANK_CALL_BASE_URL
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def disbursement(data):
|
def disburse_loan(data):
|
||||||
api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/Disbursement"
|
api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/DisburseLoan"
|
||||||
logger.info(f"Calling Disbursement endpoint with data: {data}")
|
logger.info(f"Calling DisburseLoan endpoint with data: {data}")
|
||||||
|
|
||||||
# Check if the transaction exists
|
# Check if the transaction exists
|
||||||
logger.info(f"Checking if transaction exists")
|
logger.info(f"Checking if transaction exists")
|
||||||
@@ -50,7 +50,6 @@ class SimbrellaClient:
|
|||||||
interest_fee = loan_charges.get("INTEREST")['amount']
|
interest_fee = loan_charges.get("INTEREST")['amount']
|
||||||
insurance_fee = loan_charges.get("INSURANCE")['amount']
|
insurance_fee = loan_charges.get("INSURANCE")['amount']
|
||||||
|
|
||||||
|
|
||||||
disbursement_data ={
|
disbursement_data ={
|
||||||
"requestId": data['requestId'],
|
"requestId": data['requestId'],
|
||||||
"transactionId": data['transactionId'],
|
"transactionId": data['transactionId'],
|
||||||
@@ -73,17 +72,12 @@ class SimbrellaClient:
|
|||||||
logger.info(f"Disbursement response: {response.json()}")
|
logger.info(f"Disbursement response: {response.json()}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(f"Failed to call Disbursement endpoint: {e}")
|
logger.info(f"Failed to call Disbursement endpoint: {e}")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
#Calling CollectLoan endpoint with data: {'transactionId': 'TRX1747960765928545', 'customerId': 'CID0000055362', 'productId': '101', 'debtId': '9590'}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def collect_loan(data):
|
def collect_loan(data):
|
||||||
@@ -101,7 +95,7 @@ class SimbrellaClient:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
collect_loan_data = {
|
collect_loan_data = {
|
||||||
"transactionId": "T002",
|
"transactionId": data['transactionId'],
|
||||||
"fbnTransactionId": "FBN20231123",
|
"fbnTransactionId": "FBN20231123",
|
||||||
"debtId": data['debtId'],
|
"debtId": data['debtId'],
|
||||||
"customerId": data['customerId'],
|
"customerId": data['customerId'],
|
||||||
@@ -109,12 +103,29 @@ class SimbrellaClient:
|
|||||||
"productId": data['productId'],
|
"productId": data['productId'],
|
||||||
"collectAmount": 80000,
|
"collectAmount": 80000,
|
||||||
"penalCharge": 0,
|
"penalCharge": 0,
|
||||||
|
"channel": "USSD",
|
||||||
"collectionMethod": 1,
|
"collectionMethod": 1,
|
||||||
"lienAmount": 80000,
|
"lienAmount": 80000,
|
||||||
"countryId": "01",
|
"countryId": "01",
|
||||||
"comment": "Testing CollectionLoanRequest"
|
"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:
|
try:
|
||||||
logger.info(f"Here is your CollectLoan Request data ***** : {collect_loan_data}")
|
logger.info(f"Here is your CollectLoan Request data ***** : {collect_loan_data}")
|
||||||
response = requests.post(api_url, json=collect_loan_data, headers=get_headers())
|
response = requests.post(api_url, json=collect_loan_data, headers=get_headers())
|
||||||
|
|||||||
Reference in New Issue
Block a user