from marshmallow import ValidationError from app.utils.logger import logger from app.api.helpers.response_helper import ResponseHelper from app.api.schemas.new_transaction_check import NewTransactionCheckSchema from flask import request, jsonify 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