Exemple #1
0
    def post(payment_id):
        """Create the Transaction records."""
        current_app.logger.info('<Transaction.post')
        request_json = request.get_json()

        # Validate the input request
        valid_format, errors = schema_utils.validate(request_json,
                                                     'transaction_request')

        if not valid_format:
            return jsonify({
                'code': 'PAY007',
                'message': schema_utils.serialize(errors)
            }), HTTPStatus.BAD_REQUEST

        try:
            response, status = TransactionService.create(
                payment_id, request_json).asdict(), HTTPStatus.CREATED
        except BusinessException as exception:
            response, status = {
                'code': exception.code,
                'message': exception.message
            }, exception.status
        current_app.logger.debug('>Transaction.post')
        return jsonify(response), status
Exemple #2
0
    def post(payment_identifier):
        """Create the Transaction records."""
        current_app.logger.info('<Transaction.post')
        redirect_uri = flask.request.args.get('redirect_uri')
        try:
            if not redirect_uri:
                raise BusinessException(Error.PAY007)

            response, status = TransactionService.create(payment_identifier, redirect_uri).asdict(), HTTPStatus.CREATED
        except BusinessException as exception:
            response, status = {'code': exception.code, 'message': exception.message}, exception.status
        current_app.logger.debug('>Transaction.post')
        return jsonify(response), status
Exemple #3
0
    def post(payment_id):
        """Create the Transaction records."""
        current_app.logger.info('<Transaction.post')
        request_json = request.get_json()

        # Validate the input request
        valid_format, errors = schema_utils.validate(request_json,
                                                     'transaction_request')

        if not valid_format:
            return error_to_response(
                Error.INVALID_REQUEST,
                invalid_params=schema_utils.serialize(errors))

        try:
            response, status = TransactionService.create(
                payment_id, request_json).asdict(), HTTPStatus.CREATED
        except BusinessException as exception:
            return exception.response()
        current_app.logger.debug('>Transaction.post')
        return jsonify(response), status