feat: paygw_moneta 1.0.0, MONETA.Assistant payment gateway for Moodle
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// 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.Assistant.
|
||||
*
|
||||
* @package paygw_moneta
|
||||
* @copyright 2026 Moneta Labs {@link https://moneta.ru/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use paygw_moneta\local\BuyerNotifier;
|
||||
use paygw_moneta\local\GatewayConfigRepository;
|
||||
use paygw_moneta\local\order\OrderFactory;
|
||||
use paygw_moneta\local\order\TransactionRepository;
|
||||
use paygw_moneta\local\PaymentFormPage;
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
require_login();
|
||||
require_sesskey();
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
throw new moodle_exception('invalidrequest', 'error');
|
||||
}
|
||||
|
||||
$component = required_param('component', PARAM_COMPONENT);
|
||||
$paymentarea = required_param('paymentarea', PARAM_AREA);
|
||||
$itemid = required_param('itemid', PARAM_INT);
|
||||
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url('/payment/gateway/moneta/pay.php');
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('confirmpayment', 'paygw_moneta'));
|
||||
$PAGE->set_heading(get_string('confirmpayment', 'paygw_moneta'));
|
||||
|
||||
$config = (new GatewayConfigRepository())->forPayable($component, $paymentarea, $itemid);
|
||||
$order = (new OrderFactory(new TransactionRepository()))->start(
|
||||
component: $component,
|
||||
paymentArea: $paymentarea,
|
||||
itemId: $itemid,
|
||||
user: $USER,
|
||||
config: $config,
|
||||
created: $created,
|
||||
);
|
||||
|
||||
if ($created && $config->sendPaymentLink) {
|
||||
(new BuyerNotifier())->notifyPaymentLink($order);
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->render_from_template('paygw_moneta/payment_form', PaymentFormPage::context($order, $config));
|
||||
echo $OUTPUT->footer();
|
||||
Reference in New Issue
Block a user