def post(): """Create the payment records.""" current_app.logger.info('<Payment.post') request_json = request.get_json() current_app.logger.debug(request_json) # Validate the input request valid_format, errors = schema_utils.validate(request_json, 'payment_request') if not valid_format: return jsonify({ 'code': 'PAY999', 'message': schema_utils.serialize(errors) }), HTTPStatus.BAD_REQUEST # Check if user is authorized to perform this action check_auth(request_json.get('businessInfo').get('businessIdentifier'), contains_role=EDIT_ROLE) try: response, status = PaymentService.create_payment( request_json), HTTPStatus.CREATED except BusinessException as exception: response, status = { 'code': exception.code, 'message': exception.message }, exception.status except ServiceUnavailableException as exception: response, status = { 'code': exception.status_code }, HTTPStatus.BAD_REQUEST current_app.logger.debug('>Payment.post') return jsonify(response), status
def post(): """Create the payment records.""" current_app.logger.info('<Payment.post') request_json = request.get_json() current_app.logger.debug(request_json) # Validate the input request valid_format, errors = schema_utils.validate(request_json, 'payment_request') if not valid_format: return error_to_response( Error.INVALID_REQUEST, invalid_params=schema_utils.serialize(errors)) # Check if user is authorized to perform this action business_identifier = get_str_by_path( request_json, 'businessInfo/businessIdentifier') corp_type_code = get_str_by_path(request_json, 'businessInfo/corpType') authorization = check_auth(business_identifier=business_identifier, corp_type_code=corp_type_code, contains_role=EDIT_ROLE) try: response, status = PaymentService.create_payment( request_json, authorization), HTTPStatus.CREATED except (BusinessException, ServiceUnavailableException) as exception: return exception.response() current_app.logger.debug('>Payment.post') return jsonify(response), status
def post(): """Create the payment records.""" current_app.logger.info('<Payment.post') request_json = request.get_json() # Validate the input request valid_format, errors = schema_utils.validate(request_json, 'payment_request') if not valid_format: return jsonify({'code': 'PAY999', 'message': schema_utils.serialize(errors)}), HTTPStatus.BAD_REQUEST try: response, status = PaymentService.create_payment(request_json, g.jwt_oidc_token_info.get('preferred_username', None)), HTTPStatus.CREATED except BusinessException as exception: response, status = {'code': exception.code, 'message': exception.message}, exception.status current_app.logger.debug('>Payment.post') return jsonify(response), status