User balance

Module refers to the part of the CMS "Online shop" and can be installed optionally.

The module allows the user to attach to a balance, to replenish it through payment sisetemy and spend on goods.

Module is available in the "Payment" section in the administrative part of the site.

Connection

Подключаемая часть – файл modules/balance/balance.inc.php. В нем описан класс Balance_inc. В модуле к объекту класса можно обратиться через переменную $this->diafan->_balance. Экземпляр класса создается при первом вызове переменной.

Методы

float get ([integer $user_id = false]) – Возврат текущего баланса пользователя.

  • integer $user_id: ID пользователя. По умолчанию текущий пользователь

Example:

echo 'Your balance: $'.$this->diafan->_balance->get();
// output:
// You balance: $30

array details (integer $user_id) – Возврат информаци о плательщике.

  • integer $user_id: ID пользователя

void set (integer $user_id, float $summ, [string $type = 'summ']) – Изменение текущего баланса пользователя.

  • integer $user_id: ID пользователя. По умолчанию текущий пользователь
  • float $summ: новая сумма
  • string $type: тип операции: summ – изменение всей суммы на балансе, plus – добавление, minus – вычитание

Example:

// adds the current user $300 on the balance
$this->diafan->_balance->set(0, 300, 'plus');

void pay (array $pay) – Добавление средств на баланс пользователя.

  • array $pay: данные платежа

Example:

// guides the user recharge ID=4
$pay = DB::fetch_array("SELECT * FROM {payment_history} WHERE element_id=4 AND module_name='balance'");
$this->diafan->_balance->pay($pay);

Balance

User balance

View and edit user can balance the tab "Balance". Link "Add" is needed in order to add funds for the balance of the user, which is not yet on the list. Entries appear in addition to balance in the user's part.

Edit of user balance

When editing a balance of the following fields can be set.

Основные:

  • User name.
  • Balance.

Settings

Settings

  • Currency name – Name of balance currency. The parameter has different values for different language versions of the site.
  • Message about balance refill before payment – Message received by the user upon termination of balance replenishment. The parameter has different values for different language versions of the site.
  • Payment description – Used payment systems. You can add:
    • %id – number of payment.
    The parameter has different values for different language versions of the site.
  • Payment is successfully accepted – Message for the user if payment is successfully accepted by payment system.
  • Payment is not accepted – Message for the user if payment is not accepted by payment system.
  • E-mail subject to the user about balance refill – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru),
    • %id – number of payment.
    The parameter has different values for different language versions of the site.
  • Message to the user about balance replenishment – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru),
    • %payment – payment method,
    • %fio – name of the user to replenish the balance,
    • %id – number of payment.
    The parameter has different values for different language versions of the site.
  • E-mail subject to the administrator about balance refill – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru),
    • %id – number of payment.
  • E-mail message to the administrator about balance refill – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru),
    • %payment – payment method,
    • %fio – name of the user to replenish the balance,
    • %id – number of payment.
  • E-mail for administrator notifications – Possible values:
    • e-mail, specified as a parameter of the site;
    • other (when selected, an additional field appears register e-mail).
  • Notify about balance replenishment by SMS – Possibility to send SMS to the administrator at balance replenishment. Parameter can be enabled if SMS notification are set in Site parameters.
  • Phone number in federal format – Phone number for SMS notifications for the administrator about balance replenishment. This parameter appears if the option marked "Notify about balance replenishment by SMS".
  • Notification message – Text of message for SMS notifications for the administrator about balance replenishment. Maximum 800 characters. This parameter appears if the option marked "Notify about balance replenishment by SMS".

Database

{balance} – Баланс пользователей

Files

The module is located in the folder modules/balace and arranged classically.

  1. modules/balance/admin/balance.admin.php – Редактирование баланса пользователей;

  2. modules/balance/admin/balance.admin.config.php – Module settings;

  3. modules/balance/balance.php – Controller;

  4. modules/balance/balance.action.php – Processes the received data from the form;

  5. modules/balance/balance.inc.php – Подключение модуля «Баланс пользователя»;

  6. modules/balance/balance.install.php – Module installation;

  7. modules/balance/balance.model.php – Модель модуля «Баланс пользователя»;

  8. modules/balance/views/balance.view.form.php – Шаблон формы пополнения баланса пользователя;

  9. modules/balance/views/balance.view.payment.php – Шаблон формы платежной системы;

  10. modules/balance/views/balance.view.result.php – Шаблон подтверждения/опровержения платежа.