feat: paygw_moneta 1.0.0, MONETA.Assistant payment gateway for Moodle
This commit is contained in:
+72
@@ -0,0 +1,72 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Возврат покупателя с платёжной формы (Success URL / Fail URL / Return URL).
|
||||
*
|
||||
* Возврат браузера не доказывает оплату: доступ выдаёт только Pay URL.
|
||||
* Здесь лишь показываем состояние заказа и ведём дальше.
|
||||
*
|
||||
* @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\order\TransactionRepository;
|
||||
use paygw_moneta\local\protocol\AssistantTransactionId;
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
$transactionid = required_param('MNT_TRANSACTION_ID', PARAM_RAW_TRIMMED);
|
||||
$outcome = optional_param('outcome', 'success', PARAM_ALPHA);
|
||||
|
||||
$merchantorderid = AssistantTransactionId::parse($transactionid);
|
||||
|
||||
$order = $merchantorderid === null ? null : (new TransactionRepository())->findByMerchantOrderId($merchantorderid);
|
||||
if ($order === null) {
|
||||
throw new moodle_exception('error:ordernotfound', 'paygw_moneta');
|
||||
}
|
||||
if ($order->userId !== (int) $USER->id && !is_siteadmin()) {
|
||||
throw new moodle_exception('error:ordernotfound', 'paygw_moneta');
|
||||
}
|
||||
|
||||
$successurl = core_payment\helper::get_success_url($order->component, $order->paymentArea, $order->itemId);
|
||||
if ($order->isPaid()) {
|
||||
redirect($successurl, get_string('paymentconfirmed', 'paygw_moneta'), 0, \core\output\notification::NOTIFY_SUCCESS);
|
||||
}
|
||||
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url('/payment/gateway/moneta/return.php', ['MNT_TRANSACTION_ID' => $transactionid, 'outcome' => $outcome]);
|
||||
$PAGE->set_title(get_string('paymentpending', 'paygw_moneta'));
|
||||
$PAGE->set_heading(get_string('paymentpending', 'paygw_moneta'));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($outcome === 'success') {
|
||||
echo $OUTPUT->notification(
|
||||
get_string('paymentpending_help', 'paygw_moneta'),
|
||||
\core\output\notification::NOTIFY_INFO,
|
||||
);
|
||||
} else {
|
||||
echo $OUTPUT->notification(
|
||||
get_string('paymentnotcompleted', 'paygw_moneta'),
|
||||
\core\output\notification::NOTIFY_WARNING,
|
||||
);
|
||||
}
|
||||
|
||||
echo $OUTPUT->single_button($successurl, get_string('continue'), 'get');
|
||||
echo $OUTPUT->footer();
|
||||
Reference in New Issue
Block a user