. /** * Создаёт заказ и отправляет покупателя на платёжную форму 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();