Ejemplo n.º 1
0
    def put(payment_id):
        """Update the payment records."""
        current_app.logger.info('<Payment.put')
        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': 'PAY003',
                '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'),
                   one_of_roles=[EDIT_ROLE])

        try:
            response, status = (
                PaymentService.update_payment(payment_id, request_json),
                HTTPStatus.OK,
            )
        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.put')
        return jsonify(response), status
Ejemplo n.º 2
0
    def put(payment_id):
        """Update the payment records."""
        current_app.logger.info('<Payment.put')
        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
        authorization = check_auth(
            request_json.get('businessInfo').get('businessIdentifier'),
            one_of_roles=[EDIT_ROLE])

        try:
            response, status = (
                PaymentService.update_payment(payment_id, request_json,
                                              authorization),
                HTTPStatus.OK,
            )
        except (BusinessException, ServiceUnavailableException) as exception:
            return exception.response()
        current_app.logger.debug('>Payment.put')
        return jsonify(response), status
Ejemplo n.º 3
0
    def put(payment_id):
        """Update the payment records."""
        current_app.logger.info('<Payment.put')
        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': 'PAY003', 'message': schema_utils.serialize(errors)}), HTTPStatus.BAD_REQUEST

        try:
            response, status = (
                PaymentService.update_payment(
                    payment_id, request_json, g.jwt_oidc_token_info.get('preferred_username', None)
                ),
                HTTPStatus.OK,
            )
        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.put')
        return jsonify(response), status