Links

Создание модуля выплат

Структура файлов:

  • plugins/payouts/__NAME_PAYOUT - папка с модулем
  • ./icon.png or ./icon.jpg - иконка модуля 1:1 (рекомендуемый 150px на 150px)
  • ./configure.js - файл правил конфигурация модуля также конфигурирование доступов
  • ./index.js - Класс модуля (точка входа в модуль)
  • ./template/admin.html - Шаблон админ страници настроек модуля (vue template)
  • ./template/admin.js - файл експорта клиентской логики js (vue js)

configure.js:

Пример файла и его функции
module.exports.type = 'payout'; // тип модуля (payout)
module.exports.title = 'Title of payout'; // заголовок модуля для отображения в админке (до 200 символов)
module.exports.name = 'Name service'; // Имя модуля для отображения в валютах (до 50 символов)
module.exports.required_npm = []; //массив необходимых npm модулей
//массив xml валют с которыми работает данный модуль
module.exports.allow_XML = [
"CARDUSD",
"WMZ",
];
// объект конфигурации по умолчание (будет установлен в config/app_config.json)
module.exports.default_config = {
clientID: '',
clientSecret: '',
clientPassword: '',
};
// типы данных в конфигурации где 1 публичный ключ 2 секретный (не будет передаваться каждый раз админу)
module.exports.required_config = {
clientID: 1,
clientSecret: 2, // hide
clientPassword: 2, // hide
};

index.js:

Должен иметь экспортный класс
Как работать с конфигурацией:
const id_key = __dirname.split('/').slice(-1)[0];
const config = require('../main_config')(id_key);
const clientID = await config.get('clientID') //получить конфигурацию по ключу clientID
Пример конструктора
constructor(API) {
this.API = API;
this.allowIPs = [];
this.id_key = id_key;
this.web_domain = config.get('domain');
this.schema = config.get('schema');
}

Function getFields(lang,xml){}

Param lang has Sting:
ru, en, etc... - Краткий ключ языка
Param xml has Sting:
Пример конструктора
Should Return Array (when xml is support)
// example
return [{
_id: 'account_p',
name: 'Advanced account USD',
placeholder: 'U000000',
regexp: '^U+[0-9]{6,12}$',
regexp_error: "Account incorrect",
required: true,
}];
Should Return NULL (when xml is not support)

Function transfer(order){}

Param order has object:
key
Type
Required
Value
order.uid
Number
YES
order uid
order.outAmount
Float
YES
order outAmount
order.outXML
String
YES
XML of currency for withdrawal
order.outValues
Object
YES
Order requisites
//пример объекта order.outValues
order.outValues ={
account_p:'U000000'
}
// key its from getFields ._id
// value entered client
Should Return Promise -> resolve (when transfer success) {Object}
key
Type
Required
Value
ok
Number
YES
1 - success
transaction
String
YES
transaction id or transfer id
to
String
YES
Wallet id or other requisites who received payment
currency
String
YES
Currency ISO (example USD)
amount
Float
YES
amount of transfer
fee
Float
No
Fee of tx (will add comment for admin)
note
String
No
Note for order (will show to user)
Should Return Promise -> reject (when transfer fail) {String}
Message of fail