Update repayment.py
This commit is contained in:
@@ -62,23 +62,25 @@ class RepaymentService(BaseService):
|
|||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return ResponseHelper.error(result_description="Balance Check failed")
|
return ResponseHelper.error(result_description="Balance Check failed")
|
||||||
|
|
||||||
response = response.json()
|
|
||||||
|
try:
|
||||||
|
response = response.json()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Balance Check failed: Invalid JSON response - {str(e)}")
|
||||||
|
return ResponseHelper.error(result_description="Balance Check failed")
|
||||||
|
|
||||||
logger.info(f"This is Response (Balance Check): {str(response)}", exc_info=True)
|
logger.info(f"This is Response (Balance Check): {str(response)}", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
if not response or response['responseCode'] != '00':
|
verify_account_balance_response = response.get('isSufficient', None) if response else None
|
||||||
|
|
||||||
if response:
|
if verify_account_balance_response is None:
|
||||||
logger.error(f"{response['responseMessage']}")
|
return ResponseHelper.error(result_description="Balance Check failed")
|
||||||
|
|
||||||
return ResponseHelper.error(result_description=f"Balance Check failed")
|
if verify_account_balance_response in [False, "false"]:
|
||||||
|
logger.error("Balance Check failed: Insufficient Account Balance")
|
||||||
|
return ResponseHelper.error(result_description="Insufficient Account Balance")
|
||||||
|
|
||||||
verify_account_balance_response = response['isSufficient']
|
|
||||||
|
|
||||||
if not verify_account_balance_response or verify_account_balance_response in [False, "false"]:
|
|
||||||
logger.error(f"Balance Check failed: Insufficient Account Balance")
|
|
||||||
return ResponseHelper.error(result_description=f"Insufficient Account Balance")
|
|
||||||
|
|
||||||
|
|
||||||
# Save the repayment details
|
# Save the repayment details
|
||||||
|
|||||||
Reference in New Issue
Block a user