diff --git a/app/routes/autocall.py b/app/routes/autocall.py index 1f8d50e..8dc07fa 100644 --- a/app/routes/autocall.py +++ b/app/routes/autocall.py @@ -1,3 +1,4 @@ +from threading import Thread from flask import Blueprint, request, jsonify, current_app import requests from app.extensions import db @@ -194,8 +195,16 @@ def direct_loan(): "productId": str(loan_data.get('productId', "")), "provideAmount": loan_data.get('currentLoanAmount'), } - response = SimbrellaClient.disburse_loan(data_to_process) - return response + + + logger.info(f"Starting disbursement thread for {data_to_process['transactionId']}") + thread = Thread(target=SimbrellaClient.disburse_loan, args=(data_to_process,)) + thread.start() + + return jsonify({ + "status": "success", + "message": f"Loan disbursement has been queued for processing." + }), 200 @autocall_bp.route("/direct/repayment", methods=["POST"]) def direct_repayment():