made changes on the api to match bank api
This commit was merged in pull request #6.
This commit is contained in:
@@ -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.transaction_verify import TransactionVerifySchema
|
||||
from app.api.schemas.transaction_verify import (
|
||||
TransactionVerifySchema,
|
||||
TransactionVerifyResponseSchema
|
||||
)
|
||||
|
||||
|
||||
class TransactionVerifyService:
|
||||
@@ -26,32 +29,32 @@ class TransactionVerifyService:
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"type": "TransactionCheckResponse",
|
||||
"nativeId": "FBN20191031104405CN621868",
|
||||
"customerId": "CN621868",
|
||||
"accountId": "2017821799",
|
||||
"responseCode": "00",
|
||||
"responseDescr": "Success",
|
||||
"fullDescription": "Collect Status retrieved successfully.",
|
||||
"customerId": validated_data.get("customerId"),
|
||||
"accountId": validated_data.get("accountId"),
|
||||
"providedAmount": 0.0,
|
||||
"collectedAmount": 7.50,
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Collect Status retrieved successfully."
|
||||
"transactionId": validated_data.get("transactionId"),
|
||||
"transactionType": validated_data.get("transactionType")
|
||||
}
|
||||
|
||||
# Validate and serialize response with TransactionVerifyResponseSchema
|
||||
response_schema = TransactionVerifyResponseSchema()
|
||||
serialized_response = response_schema.dump(response_data)
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Transaction verification completed successfully"
|
||||
# )
|
||||
|
||||
return response_data
|
||||
return jsonify(serialized_response), 200
|
||||
|
||||
except ValidationError as err:
|
||||
logger.error(f"Validation Error: {err.messages}")
|
||||
return jsonify({
|
||||
"message": "Validation exception"
|
||||
}) , 422
|
||||
"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
|
||||
}), 500
|
||||
|
||||
Reference in New Issue
Block a user