62 lines
2.3 KiB
Python
62 lines
2.3 KiB
Python
# coding: utf-8
|
|
|
|
from SWSCloudCore import models
|
|
|
|
|
|
class ControllerPayments:
|
|
def __init__(self, **args):
|
|
self.args = args
|
|
|
|
def balance_update(self, transaction_id, amount):
|
|
user = models.UsersBalanceTransactions.select().where(models.UsersBalanceTransactions.id == transaction_id)[0]
|
|
balance = models.UsersBalance.get(models.UsersBalance.user == user.user.id)
|
|
balance.balance += float(amount)
|
|
balance.save()
|
|
|
|
def transaction_create(self, user_id, amount, method, status='process'):
|
|
# create transaction data to database
|
|
transaction = models.UsersBalanceTransactions(user=user_id, amount=amount, status=status, method=method)
|
|
transaction.save()
|
|
return transaction.id
|
|
|
|
def transaction_set_notified(self, transaction_id, notified):
|
|
# update transaction signature
|
|
transaction = models.UsersBalanceTransactions.get(models.UsersBalanceTransactions.id == transaction_id)
|
|
transaction.notified = notified
|
|
transaction.save()
|
|
return True
|
|
|
|
def transaction_set_status(self, transaction_id, status):
|
|
# update transaction signature
|
|
transaction = models.UsersBalanceTransactions.get(models.UsersBalanceTransactions.id == transaction_id)
|
|
transaction.status = status
|
|
transaction.save()
|
|
return True
|
|
|
|
# def settings_exists(self, key):
|
|
# if models.Settings.select().where(models.Settings.key == key).count() == 0:
|
|
# return False
|
|
# return True
|
|
|
|
# def settings_get(self, keys):
|
|
# if models.Settings.select().where(models.Settings.key << keys).count() == 0:
|
|
# return dict()
|
|
#
|
|
# settings = dict()
|
|
# # извлекаем настройки и определяем их в глобальную переменную
|
|
# for setting in models.Settings.select(
|
|
# models.Settings.key, models.Settings.val
|
|
# ).where(models.Settings.key << keys).execute():
|
|
# settings[setting.key] = setting.val
|
|
# return settings
|
|
|
|
|
|
class ControllerPaymentsRobokassa(ControllerPayments):
|
|
__settings__ = {
|
|
'PAY_ROBOKASSA_ENABLED': '',
|
|
'PAY_ROBOKASSA_MODE': '',
|
|
'PAY_ROBOKASSA_LOGIN': '',
|
|
'PAY_ROBOKASSA_PASSWORD1': '',
|
|
'PAY_ROBOKASSA_PASSWORD2': '',
|
|
}
|
|
|