예제 #1
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT

    db.init_app(app)
    ma.init_app(app)

    app.register_blueprint(API_BLUEPRINT)
    app.register_blueprint(OPS_BLUEPRINT)
    app.after_request(convert_to_camel)

    setup_jwt_manager(app, jwt)

    ExceptionHandler(app)

    @app.after_request
    def add_version(response):  # pylint: disable=unused-variable
        version = get_run_version()
        response.headers['API'] = f'pay_api/{version}'
        return response

    register_shellcontext(app)

    return app
예제 #2
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    db.init_app(app)
    ma.init_app(app)

    if run_mode != 'migration':

        # Configure Sentry
        if app.config.get('SENTRY_DSN', None):  # pragma: no cover
            sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'),
                            integrations=[FlaskIntegration()])
        # pylint: disable=import-outside-toplevel
        from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT

        app.register_blueprint(API_BLUEPRINT)
        app.register_blueprint(OPS_BLUEPRINT)
        app.after_request(convert_to_camel)

        setup_jwt_manager(app, jwt)

        ExceptionHandler(app)

        @app.after_request
        def add_version(response):  # pylint: disable=unused-variable
            version = get_run_version()
            response.headers['API'] = f'pay_api/{version}'
            return response

        register_shellcontext(app)
        build_cache(app)
    return app
예제 #3
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    # initialize tracer
    api_tracer = ApiTracer("Payment Services")
    global tracing  # pylint: disable=global-statement,invalid-name
    tracing = ApiTracing(api_tracer.tracer)

    from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT

    db.init_app(app)
    ma.init_app(app)

    app.register_blueprint(API_BLUEPRINT)
    app.register_blueprint(OPS_BLUEPRINT)

    setup_jwt_manager(app, jwt)

    @app.after_request
    def add_version(response):  # pylint: disable=unused-variable
        version = get_run_version()
        response.headers['API'] = f'pay_api/{version}'
        return response

    register_shellcontext(app)

    return app
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)

    app.config.from_object(config.CONFIGURATION[run_mode])

    db.init_app(app)
    ma.init_app(app)

    setup_jwt_manager(app, jwt)

    register_shellcontext(app)

    return app
예제 #5
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    from pay_api.models import db, ma

    app = Flask(__name__)

    app.config.from_object(config.CONFIGURATION[run_mode])
    app.logger.info(f'<<<< Starting Payment Jobs >>>>')
    db.init_app(app)
    ma.init_app(app)

    register_shellcontext(app)

    return app
예제 #6
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)

    app.config.from_object(config.CONFIGURATION[run_mode])
    # Configure Sentry
    if app.config.get('SENTRY_DSN', None):  # pragma: no cover
        sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'),
                        integrations=[FlaskIntegration()])
    db.init_app(app)
    ma.init_app(app)

    register_shellcontext(app)

    return app
예제 #7
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    db.init_app(app)
    ma.init_app(app)

    # Init Flask Admin
    init_flask_admin(app)
    Keycloak(app)

    @app.route('/')
    def index():
        return redirect('/admin/feecode/')

    return app
예제 #8
0
import nats
from entity_queue_common.service import QueueServiceManager
from entity_queue_common.service_utils import QueueException, logger
from flask import Flask
from pay_api.models import db

from reconciliations import config
from reconciliations.cgi_reconciliations import reconcile_distributions
from reconciliations.payment_reconciliations import reconcile_payments

qsm = QueueServiceManager()  # pylint: disable=invalid-name
APP_CONFIG = config.get_named_config(os.getenv('DEPLOYMENT_ENV', 'production'))
FLASK_APP = Flask(__name__)
FLASK_APP.config.from_object(APP_CONFIG)
db.init_app(FLASK_APP)


async def process_event(event_message, flask_app):
    """Render the payment status."""
    if not flask_app:
        raise QueueException('Flask App not available.')

    with flask_app.app_context():
        if (message_type := event_message.get(
                'type', None)) == 'bc.registry.payment.casSettlementUploaded':
            await reconcile_payments(event_message)
        elif message_type == 'bc.registry.payment.cgi.ACKReceived':
            await reconcile_distributions(event_message)
        elif message_type == 'bc.registry.payment.cgi.FEEDBACKReceived':
            await reconcile_distributions(event_message, is_feedback=True)