console/SWSCloudCore/controllers/payments/__init__.py
Vyacheslav Anzhiganov d6f4a0e348 Merge commit 'bf9e0731bcd036956918559645d2a8cd4a3a2c94'
# Conflicts:
#	README.md
#	SWSCloudCore/__init__.py
#	SWSCloudCore/static/css/gocloud.css
#	SWSCloudCore/static/css/hp.css
#	SWSCloudCore/static/css/normalize.css
#	SWSCloudCore/static/css/style.css
#	SWSCloudCore/templates/default/_header.html
#	SWSCloudCore/templates/default/containers/index.html
#	SWSCloudCore/templates/default/homepage/index.en.html
#	SWSCloudCore/templates/default/id/_account_information_edit.html
#	SWSCloudCore/templates/default/id/_account_information_view.html
#	SWSCloudCore/templates/default/id/billing.html
#	SWSCloudCore/templates/default/id/edit.html
#	SWSCloudCore/templates/default/tasks/index.html
#	SWSCloudCore/templates/errors/403.html
#	SWSCloudCore/templates/errors/404.html
#	SWSCloudCore/templates/errors/410.html
#	SWSCloudCore/templates/errors/500.html
#	SWSCloudCore/views/account/__init__.py
#	SWSCloudCore/views/api/__init__.py
#	SWSCloudCore/views/containers/__init__.py
#	SWSCloudCore/views/payments/__init__.py
#	app/static/css/app.css
#	app/static/css/gocloud.css
#	app/templates/default/_footer.html
#	app/templates/default/errors/404.html
#	app/templates/default/errors/410.html
#	app/templates/default/errors/500.html
#	app/templates/default/homepage/index.html
#	app/templates/default/id/_account_information_view.html
#	app/templates/default/settings/profile/_account_information_view.html
#	app/templates/default/tasks/index.html
#	app/templates/default/tasks/index.ru.html
#	app/templates/errors/404.html
#	app/templates/errors/410.html
#	app/templates/errors/500.html
#	kb/README.md
2016-04-02 02:20:12 +03:00

81 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding: utf-8
from SWSCloudCore import models
class ControllerPayments:
def __init__(self, **args):
self.args = args
def balance_update(self, transaction_id, amount):
"""
Обновление баланса пользователя
:param transaction_id:
:param amount:
:return:
"""
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, status='process'):
"""
Создание записи о транзакции со статусом 'proccess'
:param user_id:
:param amount:
:param status:
:return:
"""
# create transaction data to database
transaction = models.UsersBalanceTransactions(user=user_id, amount=amount, status=status)
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):
"""
Обновить статус [fail, success, process]
:param transaction_id:
:param status:
:return:
"""
# 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': '',
}