示例#1
0
import json
# logging
from logzero import logger
from flaskapp.api.common import get_trans_id
from envparse import Env

env = Env(TerminalID=str, TermialPass=str)
env.read_envfile()

# token authentication handling
from flaskapp.auth import jwt_required

# get db connection
from flaskapp.mongoconnection import db_init
paydnadb = db_init()

from flaskapp.api.tutuka import tutuka_xmlrpc
xml_client = tutuka_xmlrpc.Tutuka_XMLRPC({
    'terminalID':
    env('TerminalID'),
    'terminalPassword':
    env('TerminalPass')
})

bp = Blueprint('profiles', __name__, url_prefix='/api/profiles')
CORS(bp)


def pid_to_name(pid):
    return paydnadb.profiles.find_one({'_id': pid}, {'name': 1}).get('name')
示例#2
0
# Handle queing, logging and loading of transactions
from flaskapp import mongoconnection
paydna = mongoconnection.db_init()

# other imports

# Hard configs
TRANS_TYPES = ['load', 'deduct', 'transfer']


def _get_scheme_load_fee(scheme_id):
    # get the load fee value from the db
    scheme_dets = paydna.schemes.find_one({'_id': scheme_id})
    if scheme_dets:
        return scheme_dets.get('loadFee', 0)
    else:
        return None


def _get_card_dets(card_id):
    # get the card details for traversing
    dets = paydna.cards.find_one({'_id': card_id})
    if dets:
        return dets
    else:
        return None


def _get_transaction_id():
    id = paydna.counters.find_one({'_id': 'transaction_id'}).get('sequence')
    paydna.counters.find_one_and_update({'_id': 'transaction_id'},
示例#3
0
# app.config['UPLOAD_FOLDER_PREFIX'] = UPLOAD_FOLDER_PREFIX
app.config['ID_UPLOAD_FOLDER'] = ID_UPLOAD_FOLDER
app.config['POA_UPLOAD_FOLDER'] = POA_UPLOAD_FOLDER

# register blueprints
app.register_blueprint(tutuka.bp)
app.register_blueprint(luhn.bp)
app.register_blueprint(clients.bp)
app.register_blueprint(schemes.bp)
app.register_blueprint(profiles.bp)
app.register_blueprint(cards.bp)
app.register_blueprint(auth.bp)

# init database connection
from flaskapp.mongoconnection import db_init
db = db_init()

CORS(app, resources=r'/upload/*')

def file_type(filename):
    print(filename.rsplit('.', 1)[1])

@app.route('/', methods=['GET'])
def say_hello():
    return 'Welcome to the Flask API demo'

@app.route('/upload/<string:endpoint>', methods=['POST'])
def file_upload(endpoint):
    file = request.files['myfile']
    # read to bytes for image check and then 'rewind'
    filebytes = file.stream.read()
示例#4
0
                   make_response)
from flask_cors import CORS

import json, re
import jwt
from datetime import datetime
from functools import wraps

# logging
from logzero import logger
from flaskapp.api.common import get_trans_id
from envparse import Env

# database connection
from flaskapp import mongoconnection
db = mongoconnection.db_init()

# encryption tools
from flaskapp.api import common

from envparse import Env
env = Env(API_JWT_SECRET=str)

env.read_envfile()

# blueprint setup
bp = Blueprint('auth', __name__, url_prefix='/auth')
CORS(bp)


# jwt required decorator