72 lines
3.2 KiB
PHP
72 lines
3.2 KiB
PHP
<?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/>.
|
|
|
|
/**
|
|
* Продолжение оплаты по ссылке из письма «Ссылка на оплату».
|
|
*
|
|
* GET безопасен: заказ уже создан, страница лишь заново показывает подписанную
|
|
* форму. Открыть её может только покупатель заказа и только пока заказ открыт,
|
|
* а реквизиты, тестовый режим и цена не изменились — иначе 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\GatewayConfigRepository;
|
|
use paygw_moneta\local\order\CurrentPrice;
|
|
use paygw_moneta\local\order\TransactionRepository;
|
|
use paygw_moneta\local\order\TransactionStatus;
|
|
use paygw_moneta\local\PaymentFormPage;
|
|
|
|
require_once(__DIR__ . '/../../../config.php');
|
|
|
|
require_login();
|
|
|
|
$merchantorderid = required_param('order', PARAM_ALPHANUMEXT);
|
|
|
|
$order = TransactionRepository::isMerchantOrderId($merchantorderid)
|
|
? (new TransactionRepository())->findByMerchantOrderId($merchantorderid)
|
|
: null;
|
|
// Чужой заказ неотличим от несуществующего.
|
|
if ($order === null || $order->userId !== (int) $USER->id) {
|
|
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(PaymentFormPage::resumeUrl($order));
|
|
$PAGE->set_pagelayout('standard');
|
|
$PAGE->set_title(get_string('confirmpayment', 'paygw_moneta'));
|
|
$PAGE->set_heading(get_string('confirmpayment', 'paygw_moneta'));
|
|
|
|
$config = (new GatewayConfigRepository())->forAccount($order->accountId);
|
|
|
|
echo $OUTPUT->header();
|
|
if (PaymentFormPage::canResume($order, $config, new CurrentPrice())) {
|
|
echo $OUTPUT->render_from_template('paygw_moneta/payment_form', PaymentFormPage::context($order, $config));
|
|
} else {
|
|
$reason = $order->status === TransactionStatus::Failed ? 'error:orderinprogress' : 'error:paymentlinkexpired';
|
|
echo $OUTPUT->notification(get_string($reason, 'paygw_moneta'), \core\output\notification::NOTIFY_WARNING);
|
|
echo $OUTPUT->single_button($successurl, get_string('continue'), 'get');
|
|
}
|
|
echo $OUTPUT->footer();
|