[update]: Balance check #81
@@ -62,24 +62,26 @@ class RepaymentService(BaseService):
|
||||
if response.status_code != 200:
|
||||
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)
|
||||
|
||||
|
||||
verify_account_balance_response = response.get('isSufficient', None) if response else None
|
||||
|
||||
if verify_account_balance_response is None:
|
||||
return ResponseHelper.error(result_description="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")
|
||||
|
||||
|
||||
if not response or response['responseCode'] != '00':
|
||||
|
||||
if response:
|
||||
logger.error(f"{response['responseMessage']}")
|
||||
|
||||
return ResponseHelper.error(result_description=f"Balance Check failed")
|
||||
|
||||
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
|
||||
repayment = Repayment.create_repayment(
|
||||
|
||||
Reference in New Issue
Block a user