14 Commits

Author SHA1 Message Date
VivianDee f9e80ee088 Merge branch 'verify_balance_check' into penal_charge 2026-03-18 14:59:30 +01:00
VivianDee 2f2eb6b89f Update digifi_swagger.json 2026-03-18 14:59:07 +01:00
VivianDee ca32bfda1c [add]: penal charge 2026-03-18 14:52:46 +01:00
VivianDee 473d9568d2 [fix]: Vrifyy balance 2026-03-11 14:07:15 +01:00
VivianDee ab7cd0bedf [fix]: Verify balance 2026-03-11 13:54:56 +01:00
VivianDee bb5237797d Update verify_account_balance.py 2026-03-11 11:16:23 +01:00
VivianDee b8fde2c320 Update verify_account_balance.py 2026-03-11 11:14:31 +01:00
VivianDee c92255c0c5 [add]: Balance Check 2026-03-11 11:06:26 +01:00
CHIEFSOFT\ameye 422d60addd Amount for clooection 2025-11-03 13:25:41 -05:00
CHIEFSOFT\ameye a63d20f50e Collect Status retrieved Successfully 2025-11-02 16:38:53 -05:00
CHIEFSOFT\ameye 3fb48a08b0 responseMessage 2025-11-02 16:34:54 -05:00
CHIEFSOFT\ameye 249e624ef3 fix exytra data 2025-11-02 16:23:41 -05:00
CHIEFSOFT\ameye 630174fa8c Very data fix 2025-11-02 15:58:00 -05:00
ameye f4cd8ae162 Merge branch 'sync_payload' of DigiFi/digifi-BankEmulator into master 2025-10-29 17:13:07 +00:00
14 changed files with 266 additions and 37 deletions
+21 -5
View File
@@ -11,7 +11,8 @@ from app.api.services import (
TokenValidationService,
LienCheckService,
NewTransactionCheckService,
CompleteRACcheckService
CompleteRACcheckService,
VerifyAccountBalanceService
)
from app.utils.logger import logger
from app.api.middlewares import enforce_json
@@ -56,6 +57,22 @@ def rac_check():
except Exception as e:
logger.exception("Unhandled exception in /RACCheck route")
return jsonify({"message": "Unhandled server error"}), 500
# VerifyAccountBalance Endpoint
@api.route('/VerifyAccountBalance', methods=['POST'])
@jwt_required()
def verify_account_balance():
logger.info("VerifyAccountBalance request received")
try:
logger.info("VerifyAccountBalance inside try request received")
data = request.get_json()
response = VerifyAccountBalanceService.process_request(data)
return response
except Exception as e:
logger.exception("Unhandled exception in /VerifyAccountBalance route")
return jsonify({"message": "Unhandled server error"}), 500
# CompleteRACcheck Endpoint
@api.route('/CompleteRACcheck', methods=['POST'])
@@ -108,17 +125,16 @@ def transaction_verify():
logger.exception("Unhandled exception in /TransactionVerify route")
return jsonify({"message": "Unhandled server error"}), 500
# PenalCharge Endpoint
@api.route('/CollectPenalFee', methods=['POST'])
# CollectPenalCharge Endpoint
@api.route('/CollectPenalCharge', methods=['POST'])
@jwt_required()
def penal_charge():
try:
data = request.get_json()
# logger.info(f"PenalCharge request received: {data}")
response = PenalChargeService.process_request(data)
return response
except Exception as e:
logger.exception("Unhandled exception in /PenalCharge route")
logger.exception("Unhandled exception in /CollectPenalCharge route")
return jsonify({"message": "Unhandled server error"}), 500
+11 -10
View File
@@ -2,22 +2,23 @@ from marshmallow import Schema, fields
# This file contains the schema for penal charge operations
class PenalChargeSchema(Schema):
channel = fields.Str(allow_none=True)
transactionId = fields.Str(allow_none=True)
fbnTransactionId = fields.Str(allow_none=True)
debtId = fields.Str(allow_none=True)
accountId = fields.Str(allow_none=True)
penalCharge = fields.Float(required=True)
customerId = fields.Str(allow_none=True)
lienAmount = fields.Float(required=True)
comment = fields.Str(allow_none=True)
countryId = fields.Str(allow_none=True)
channel = fields.Str(required=True)
transactionId = fields.Str(required=True)
fbnTransactionId = fields.Str(required=True)
debtId = fields.Str(required=True)
accountId = fields.Str(required=True)
penalCharge = fields.Int(required=True)
customerId = fields.Str(required=True)
lienAmount = fields.Int(required=True)
comment = fields.Str(required=True)
countryId = fields.Str(required=True)
#represents the response schema for penal charge
class CollectPenalFeeResponseSchema(Schema):
customerId = fields.Str(allow_none=True)
transactionId = fields.Str(allow_none=True)
amountCollected = fields.Float(required=True)
lienAmount = fields.Int(allow_none=True)
accountId = fields.Str(allow_none=True)
responseCode = fields.Str(allow_none=True)
responseMessage = fields.Str(allow_none=True)
+28 -3
View File
@@ -1,6 +1,6 @@
from marshmallow import Schema, fields
class TransactionVerifySchema(Schema):
class TransactionVerifySchemaNotGood(Schema):
channel = fields.Str(allow_none=True)
accountId = fields.Str(allow_none=True)
customerId = fields.Str(allow_none=True)
@@ -9,13 +9,38 @@ class TransactionVerifySchema(Schema):
countryId = fields.Str(allow_none=True)
requestId = fields.Str(allow_none=True)
class TransactionVerifySchema(Schema):
customerId = fields.Str(allow_none=True)
accountId = fields.Str(allow_none=True)
transactionId = fields.Str(allow_none=True)
transactionType = fields.Str(allow_none=True)
fbnTransactionId = fields.Str(allow_none=True)
countryId = fields.Str(allow_none=True)
requestId = fields.Str(allow_none=True)
class TransactionVerifyResponseSchema(Schema):
responseCode = fields.Str(allow_none=True)
responseDescr = fields.Str(allow_none=True)
fullDescription = fields.Str(allow_none=True)
responseMessage = fields.Str(allow_none=True)
customerId = fields.Str(allow_none=True)
accountId = fields.Str(allow_none=True)
providedAmount = fields.Float(required=True)
collectedAmount = fields.Float(required=True)
transactionId = fields.Str(allow_none=True)
transactionType = fields.Str(allow_none=True)
transactionType = fields.Str(allow_none=True)
# '''
# verify_data = {
# "customerId": loan_data.get('customerId'),
# "accountId": loan_data.get('accountId'),
# "transactionId": loan_data.get('transactionId'),
# "transactionType": "provide",
# "fbnTransactionId": loan_data.get('transactionId'),
# "countryId": "NG",
# "requestId": loan_data.get('transactionId')
# }
# '''
+10
View File
@@ -0,0 +1,10 @@
from marshmallow import Schema, fields
from marshmallow import Schema, fields
from datetime import date
class VerifyAccountBalanceSchema(Schema):
accountId = fields.Str(required=True)
amount = fields.Str(required=True)
requestId = fields.Str(required=True)
+1
View File
@@ -9,3 +9,4 @@ from app.api.services.lien_check import LienCheckService
from app.api.services.new_transaction_check import NewTransactionCheckService
from app.api.services.complete_rac_check_service import CompleteRACcheckService
from app.api.services.generate_token import GenerateTokenService
from app.api.services.verify_account_balance import VerifyAccountBalanceService
+1 -1
View File
@@ -39,7 +39,7 @@ class CollectLoanService:
int(customerId[-1]) in [2, 7, 9]
)
if Config.MIN_AMOUNT_FOR_COLLECTION <= amountForCollection <= Config.MAX_AMOUNT_FOR_COLLECTION:
amountCollected = amountForCollection if lienAmount >= amountForCollection else 0
# amountCollected = amountForCollection if lienAmount >= amountForCollection else 0
responseDescr = "Partial Loan Collection Successful EMULATOR"
fullDescription = "Partial Loan collection completed successfully EMULATOR"
responseMessage = "Partial Loan collection completed successfully EMULATOR"
+21 -14
View File
@@ -2,7 +2,10 @@ from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.helpers.response_helper import ResponseHelper
from app.api.schemas.penal_charge import PenalChargeSchema, CollectPenalFeeResponseSchema
from app.api.schemas.penal_charge import (
PenalChargeSchema,
CollectPenalFeeResponseSchema,
)
class PenalChargeService:
@@ -24,14 +27,20 @@ class PenalChargeService:
schema = PenalChargeSchema()
validated_data = schema.load(data)
# Simulated processing logic
customerId = validated_data["customerId"]
transactionId = validated_data["transactionId"]
penalCharge = validated_data["penalCharge"]
accountId = validated_data["accountId"]
lienAmount = validated_data["lienAmount"]
response_data = {
"customerId": validated_data.get("customerId"),
"transactionId": validated_data.get("transactionId"),
"amountCollected": validated_data.get("penalCharge", 0.0),
"accountId": validated_data.get("accountId"),
"responseCode": "00",
"responseMessage": "Penal charge debited successfully"
"responseMessage": "Penal Collection Successful",
"customerId": customerId,
"transactionId": transactionId,
"amountCollected": penalCharge,
"lienAmount": lienAmount,
"accountId": accountId,
}
# Optionally validate/serialize response using schema
@@ -42,13 +51,11 @@ class PenalChargeService:
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception",
"errors": err.messages
}), 422
return (
jsonify({"message": "Validation exception", "errors": err.messages}),
422,
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}), 500
return jsonify({"message": "Internal Server Error"}), 500
+1 -1
View File
@@ -31,7 +31,7 @@ class TransactionVerifyService:
response_data = {
"responseCode": "00",
"responseDescr": "Success",
"fullDescription": "Collect Status retrieved successfully.",
"responseMessage": "Verification Status retrieved Successfully.",
"customerId": validated_data.get("customerId"),
"accountId": validated_data.get("accountId"),
"providedAmount": 0.0,
@@ -0,0 +1,50 @@
from app.api.schemas.verify_account_balance import VerifyAccountBalanceSchema
from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.helpers.response_helper import ResponseHelper
class VerifyAccountBalanceService:
@staticmethod
def process_request(data):
"""
Process the RACCheck request.
Args:
data (dict): The request data.
Returns:
tuple: JSON response and status code.
"""
try:
logger.info("Processing VerifyBalance request")
# Validate input data
schema = VerifyAccountBalanceSchema()
validated_data = schema.load(data)
account_id = validated_data["accountId"]
request_id = validated_data["requestId"]
amount = validated_data["amount"]
result = {
"responseCode": "00",
"responseMessage": "Operation Successful",
"isSufficient": True
}
return jsonify(result), 200
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception",
"errors": err.messages
}), 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}), 500
+18 -1
View File
@@ -45,6 +45,14 @@
"url": "https://www.simbrellang.net"
}
},
{
"name": "VerifyAccountBalance",
"description": "Verify Account Balance Request",
"externalDocs": {
"description": "Find out more",
"url": "https://www.simbrellang.net"
}
},
{
"name": "CompleteRACcheck",
"description": "Complete Risk Acceptance Criteria Request",
@@ -127,6 +135,9 @@
},
"/api/rac-check": {
"$ref": "swagger/paths/RACCheck.json"
},
"/api/VerifyAccountBalance": {
"$ref": "swagger/paths/VerifyAccountBalance.json"
},
"/api/CompleteRACcheck": {
"$ref": "swagger/paths/CompleteRACcheck.json"
@@ -140,7 +151,7 @@
"/api/TransactionVerify": {
"$ref": "swagger/paths/TransactionVerify.json"
},
"/api/CollectPenalFee": {
"/api/CollectPenalCharge": {
"$ref": "swagger/paths/PenalCharge.json"
},
"/api/RevokeEnableConsent": {
@@ -170,6 +181,12 @@
"RACCheckResponse": {
"$ref": "./schemas/RACCheckResponse.json"
},
"VerifyAccountBalanceRequest": {
"$ref": "./schemas/VerifyAccountBalanceRequest.json"
},
"VerifyAccountBalanceResponse": {
"$ref": "./schemas/VerifyAccountBalanceResponse.json"
},
"CompleteRACcheckRequest": {
"$ref": "./schemas/CompleteRACcheckRequest.json"
},
@@ -0,0 +1,56 @@
{
"post": {
"tags": [
"VerifyAccountBalance"
],
"summary": "Risk Acceptance Criteria Check",
"description": "Check if a customer passes the Risk Acceptance Criteria defined by the bank",
"operationId": "verifyAccountBalance",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/VerifyAccountBalanceRequest.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/VerifyAccountBalanceRequest.json"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "../schemas/VerifyAccountBalanceRequest.json"
}
}
}
},
"responses": {
"200": {
"description": "Verify Account Balance Successful",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/VerifyAccountBalanceResponse.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/VerifyAccountBalanceResponse.json"
}
}
}
},
"400": {
"description": "Invalid request"
},
"422": {
"description": "Validation exception"
},
"500": {
"description": "Internal server error"
}
}
}
}
+8 -2
View File
@@ -16,6 +16,10 @@
"format": "double",
"example": 101.2
},
"lienAmount": {
"type": "integer",
"example": 1000
},
"accountId": {
"type": "string",
"nullable": true,
@@ -32,6 +36,8 @@
"example": "Penal charge debited successfully"
}
},
"required": ["amountCollected"],
"required": [
"amountCollected"
],
"additionalProperties": false
}
}
@@ -0,0 +1,25 @@
{
"type": "object",
"properties": {
"amount": {
"type": "string",
"example": "200"
},
"requestId": {
"type": "string",
"example": "RQ621868"
},
"accountId": {
"type": "string",
"example": "2017821799"
}
},
"required": [
"accountId",
"requestId",
"amount"
],
"xml": {
"name": "VerifyAccountBalanceRequest"
}
}
@@ -0,0 +1,15 @@
{
"type": "object",
"properties": {
"isSufficient": {
"type": "string",
"example": "true"
}
},
"required": [
"isSufficient"
],
"xml": {
"name": "VerifyAccountBalanceResponse"
}
}