feat: paygw_moneta 1.0.0, MONETA.Assistant payment gateway for Moodle

This commit is contained in:
2026-09-25 16:42:38 +03:00
parent 70464af858
commit 14b386a550
65 changed files with 5377 additions and 59 deletions
+60
View File
@@ -0,0 +1,60 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Запуск оплаты через Moneta из модального окна «Выберите способ оплаты».
*
* Заказ создаёт pay.php по POST с sesskey — поэтому здесь не редирект,
* а отправка скрытой формы.
*
* @module paygw_moneta/gateways_modal
* @copyright 2026 Moneta Labs {@link https://moneta.ru/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import Config from 'core/config';
/**
* Обработчик, который ядро вызывает после выбора шлюза.
*
* @param {string} component компонент оплачиваемого объекта
* @param {string} paymentArea область оплаты
* @param {number} itemId идентификатор объекта
* @param {string} description описание из модального окна
* @returns {Promise<void>} никогда не разрешается: страница уходит на pay.php
*/
export const process = (component, paymentArea, itemId, description) => {
const form = document.createElement('form');
form.method = 'post';
form.action = `${Config.wwwroot}/payment/gateway/moneta/pay.php`;
form.style.display = 'none';
const fields = {
sesskey: Config.sesskey,
component,
paymentarea: paymentArea,
itemid: itemId,
description,
};
Object.entries(fields).forEach(([name, value]) => {
const input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = value;
form.appendChild(input);
});
document.body.appendChild(form);
form.submit();
return new Promise(() => null);
};