55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
import requests
|
|
from app.config import settings
|
|
from app.utils.auth import get_headers
|
|
from app.utils.logger import logger
|
|
from flask import jsonify
|
|
|
|
class SimbrellaClient:
|
|
|
|
BASE_URL = settings.BANK_CALL_BASE_URL
|
|
BANK_CALL_BASE_URL = settings.BANK_CALL_BASE_URL
|
|
|
|
@staticmethod
|
|
def disbursement(data):
|
|
BANK_CALL_BASE_URL = "https://bank-emulator.dev.simbrellang.net"
|
|
api_url = f"{BANK_CALL_BASE_URL}/Disbursement"
|
|
logger.info(f"BANK_CALL_BASE_URL = {BANK_CALL_BASE_URL}")
|
|
logger.info(f"Calling disbursement endpoint with data: {data}")
|
|
|
|
data={
|
|
"requestId": "RQID1743987402764",
|
|
"transactionId": "24",
|
|
"customerId": "CN437703",
|
|
"accountId": "ACN2167485",
|
|
"msisdn": "3451342",
|
|
"resultCode": "00",
|
|
"resultDescription": "Successful"
|
|
}
|
|
|
|
disbursement_data ={
|
|
"requestId": data['requestId'],
|
|
"transactionId": data['transactionId'],
|
|
"debtId": "273194670",
|
|
"customerId": data['customerId'],
|
|
"accountId": data['accountId'],
|
|
"productId": "101",
|
|
"provideAmount": 100000,
|
|
"collectAmountInterest": 5000,
|
|
"collectAmountMgtFee": 1000,
|
|
"collectAmountInsurance": 1000,
|
|
"collectAmountVAT": 75,
|
|
"countryId": "01",
|
|
"comment": "Loan Disbursement",
|
|
}
|
|
try:
|
|
logger.info(f"Here is your Disbursement Request data ****** : {disbursement_data}")
|
|
response = requests.post(api_url, json=disbursement_data, timeout=10, headers=get_headers())
|
|
logger.info(f"Disbursement response: {response.json()}")
|
|
|
|
except Exception as e:
|
|
logger.info(f"Failed to call disbursement endpoint: {e}")
|
|
#raise
|
|
return 0
|
|
|
|
# return jsonify(response.json()), response.status_code
|
|
return 1 |