5 Commits

5 changed files with 44 additions and 31 deletions
+3 -4
View File
@@ -125,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)
+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
@@ -151,7 +151,7 @@
"/api/TransactionVerify": {
"$ref": "swagger/paths/TransactionVerify.json"
},
"/api/CollectPenalFee": {
"/api/CollectPenalCharge": {
"$ref": "swagger/paths/PenalCharge.json"
},
"/api/RevokeEnableConsent": {
+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
}
}