Beispiel #1
0
 def add_new_user(self, message):
     pay = Payments()
     chat_id = message.chat.id
     username = message.from_user.username if message.from_user.username is not None else 'None'
     firstname = message.from_user.first_name if message.from_user.first_name is not None else 'None'
     lastname = message.from_user.last_name if message.from_user.last_name is not None else 'None'
     btc_addr = pay.generate_address(chat_id, 'btc')['addr']
     ltc_addr = pay.generate_address(chat_id, 'ltc')['addr']
     btc_addr_balance = 0
     ltc_addr_balance = 0
     btc_addr_info = 'None'
     ltc_addr_info = 'None'
     last_check_receipt = 0
     payment_date = 0
     last_notification = 0
     referrer = message.text.split(' ')[-1]
     comments = 'free'
     lang = 'eng'
     with sqlite3.connect(self.dbname) as conn:
         c = conn.cursor()
         columns = [
             'chat_id',
             'username',
             'firstname',
             'lastname',
             'btc_addr',
             'btc_addr_balance',
             'btc_addr_info',
             'ltc_addr',
             'ltc_addr_balance',
             'ltc_addr_info',
             'last_check_receipt',
             'payment_date',
             'last_notification',
             'referrer',
             'comments',
             'lang',
         ]
         stmt = 'INSERT INTO users ({}) VALUES ({});'.format(
             ', '.join(columns), ('?, ' * len(columns))[:-2])
         args = [
             (chat_id),
             (username),
             (firstname),
             (lastname),
             (btc_addr),
             (btc_addr_balance),
             (btc_addr_info),
             (ltc_addr),
             (ltc_addr_balance),
             (ltc_addr_info),
             (last_check_receipt),
             (payment_date),
             (last_notification),
             (referrer),
             (comments),
             (lang),
         ]
         c.execute(stmt, args)
         conn.commit()
Beispiel #2
0
class TestPayments(unittest.TestCase):
    def setUp(self):
        self.payments = Payments()

    def test_add_payments(self):
        self.payments.add_payments({"u1": 1.0, "u2": -1.0})
        self.assertAlmostEqual(1.0, self.payments.get_user("u1"))
        self.assertAlmostEqual(-1.0, self.payments.get_user("u2"))
        users = self.payments.get_all_users()
        self.assertEqual(2, len(users))
    def __init__(self):
        ''' Instantiates the application '''

        # Open and load configuration data
        with Path('./config.json').open('r') as f:
            config = json.load(f)
            try:
                const.ADMIN_EMAIL = config['admin_email']
                const.FREE_PARKING_LIMIT = config['free_parking_limit']
                const.PAYMENT_LIMIT = config['payment_limit']
                const.PARKING_RATE = config['parking_rate']
                const.BITCOIN_ADDR = config['bitcoin_addr']
            except KeyError:
                print("Bad config file")
                sys.exit(0)

        # Instantiate modules
        self.gui = GUI()
        self.payments = Payments()
        self.sensors = SensorHandler()

        self.parking_start_time = None
        self.parking_end_time = None

        # Initial State
        SV.state = State.EMPTY
Beispiel #4
0
def _setup_dependency_injection(settings: dict,
                                engine: Engine) -> injector.Injector:
    return injector.Injector(
        [
            Db(engine),
            RedisMod(settings["redis.host"]),
            Rq(),
            EventBusMod(),
            Configs(settings),
            Auctions(),
            AuctionsInfrastructure(),
            Shipping(),
            ShippingInfrastructure(),
            CustomerRelationship(),
            Payments(),
            Processes(),
        ],
        auto_bind=False,
    )
Beispiel #5
0
def _setup_dependency_injection(
        settings: dict, connection_provider: ThreadlocalConnectionProvider
) -> injector.Injector:
    return injector.Injector(  # type: ignore
        [
            Db(connection_provider),
            RedisMod(settings["redis.host"]),
            Rq(),
            EventBusMod(),
            Configs(settings),
            Auctions(),
            AuctionsInfrastructure(),
            Shipping(),
            ShippingInfrastructure(),
            CustomerRelationship(),
            Payments(),
            Processes(),
        ],
        auto_bind=False,
    )
Beispiel #6
0
    def User(self):

        login = Credentials(self.driver)
        car = Car(self.driver)
        dealership = Dealership(self.driver)
        payments = Payments(self.driver)
        residence = Residence(self.driver)
        personal = Personal(self.driver)
        employement = Employment(self.driver)

        login.Username('*****@*****.**')
        login.Password('123QWEasd')
        login.SignIn()

        car.Make('Aston Martin')
        car.Model('Vanquish')
        car.MyLocation()
        car.CarProperty('S Coupe')

        payments.TradeIn('NO')
        payments.DownPayment('50000')
        payments.NumberOfMonths('84')
        payments.Navigate()

        dealership.MyLocation()

        personal.FirstName('Bruce')
        personal.LastName('Wayne')
        personal.DOB('05/27/1938')
        personal.Phone('735-185-7301')
        personal.Navigate()

        residence.ResidenceStatus('Own')
        residence.Address('Batcave')
        residence.City('Gotham')
        residence.State('New Jersey')
        residence.Zipcode('12345')
        residence.MoveInDate('05/1939')
        residence.MortgagePayment('0')
        residence.Navigate()

        employement.EmploymentStatus('Full Time')
        employement.EmployerName('Jim Gorden')
        employement.EmployeeTitle('Batman')
        employement.EmployeeStartDate('05/2011')
        employement.EmployerPhoneNumber('714-278-9999')
        employement.GrossMonthlyIncome('10000000')
        employement.Navigate()
Beispiel #7
0
import os
import telebot
from flask import Flask, request
from telebot import types
from redis import StrictRedis as redis
from config import *
from classes import *
from dbmanager import *
from payments import Payments

bot = telebot.TeleBot(token)
server = Flask(__name__)
r = Rediska()
db = DBmanager()
pay = Payments()


@bot.message_handler(commands=['start'])
def getMessage(message):
    chat_id = message.chat.id
    #botan.track(config.botan_token, chat_id, None, message.text)
    res = db.get(message.chat.id)
    #if new user (does not exists in db)
    if res == {}:
        #Добавить в базу
        db.add_new_user(message)
        r.set(message.chat.id, {'lang': 'eng'})
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
        for lang in langs:
            markup.row(lang)
        msg = bot.send_message(message.chat.id,
Beispiel #8
0
 def setUp(self):
     self.payments = Payments()
Beispiel #9
0
def new_pay():
	resp = helpers.get_response(request) 
	loginmanager.verify_token(resp)
	payment = Payments().new(resp)
	payment.save()
	return jsonify({'status':'New payment ok', 'payment':payment._to_json()}), 200