Files
digifi-flaskA002/app/services/new_transaction_check.py
T
2025-03-21 16:26:58 +01:00

59 lines
1.9 KiB
Python

from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.schemas.new_transaction_check import NewTransactionCheckSchema
class NewTransactionCheckService:
@staticmethod
def process_request(data):
"""
Process the NewTransactionCheck request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing NewTransactionCheck request")
# Validate input data using NewTransactionCheckSchema
schema = NewTransactionCheckSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated transaction check logic
response_data = {
"transactionId": "24110114545374721",
"data": {
"transactionId": "241101",
"providedAmount": 1000.00,
"collectedAmount": 0.00,
"resultCode": "00",
"resultDescription": "Loan Provision is successful"
},
"resultCode": "00",
"resultDescription": "SUCCESS"
}
# return ResponseHelper.success(
# data=response_data,
# message="New transaction check completed successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500