[add]: offers and loan_charges, [fix]: RAC Check #10

Merged
ameye merged 1 commits from loan_charges_on_loans into master 2025-04-17 10:03:16 +00:00
3 changed files with 29 additions and 28 deletions
+24 -24
View File
@@ -1,8 +1,9 @@
import requests
import httpx
import json
from requests.auth import HTTPBasicAuth
from app.utils.logger import logger
from app.config import settings
import logging
class SimbrellaIntegration:
BASE_URL = settings.SIMBRELLA_BASE_URL
@@ -13,42 +14,41 @@ class SimbrellaIntegration:
Calls the RACCheck endpoit
"""
url = f"{SimbrellaIntegration.BASE_URL}/RACCheck"
payload = {
"customerId": customer_id,
"accountId": account_id,
"transactionId": transaction_id,
"transactionId": str(transaction_id),
"fbnTransactionId": f"FBN{transaction_id}",
"RAC_Array": [
{
"salaryAccount": True,
"bvn": "12345678901",
"crc": False,
"crms": True,
"accountStatus": "active",
"lien": False,
"noBouncedCheck": True,
"existingLoan": False,
"whitelist": True,
"noPastDueSalaryLoan": True,
"noPastDueOtherLoans": False
}
]
"SalaryAccount",
"BVN",
"BVNAttachedtoAccount",
"CRC",
"CRMS",
"AccountStatus",
"Lien",
"NoBouncedCheck",
"Whitelist",
"NoPastDueSalaryLoan",
"NoPastDueOtherLoan",
],
}
logger.error(f"This is PayLoad: {str(payload)}",exc_info=True)
logger.error(f"This is PayLoad: {str(payload)}", exc_info=True)
headers = {
'Content-Type': 'application/json',
'x-api-key': f'{settings.VALID_API_KEY}',
'App-Id': f'{settings.VALID_APP_ID}'
"Content-Type": "application/json",
"x-api-key": f"{settings.VALID_API_KEY}",
"App-Id": f"{settings.VALID_APP_ID}",
}
try:
response = requests.post(url, json=payload, timeout=10, headers=headers)
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
logger.error(f"This is Response: {str(response)}", exc_info=True)
return response.json()
return response
except Exception as e:
logger.error(f"RACCheck API call failed: {str(e)}", exc_info=True)
raise Exception(f"RACCheck API call failed: {str(e)}")
+3 -3
View File
@@ -48,17 +48,17 @@ class EligibilityCheckService(BaseService):
"message": "Invalid Customer or Account"
}), 400
db.session.flush()
# Call RACCheck
response = SimbrellaIntegration.rac_check(
customer_id = customer_id,
account_id = account_id,
transaction_id = transaction.id,
)
logger.error(f"This is Response Returned ****** : {str(response)}")
# this chck for error is not valid
if response.get("status") != 200:
if response.status_code != 200:
return jsonify({"message": "RACCheck failed"}), 400
offers = [offer.to_dict() for offer in Offer.get_all_offers()]
+2 -1
View File
@@ -25,7 +25,8 @@ flask-swagger-ui
python-dotenv
# Requests
requests
httpx
# JWT
flask-jwt-extended