2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Contains base class for payment gateways.
20 * @package core_payment
21 * @copyright 2019 Shamim Rezaie <shamim@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core_payment
;
28 * Base class for payment gateways.
30 * @copyright 2019 Shamim Rezaie <shamim@moodle.com>
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 abstract class gateway
{
35 * Returns the list of currencies that the payment gateway supports.
37 * @return string[] An array of the currency codes in the three-character ISO-4217 format
39 abstract public static function get_supported_currencies(): array;
42 * Configuration form for the gateway instance
44 * Use $form->get_mform() to access the \MoodleQuickForm instance
46 * @param \core_payment\form\account_gateway $form
48 abstract public static function add_configuration_to_gateway_form(\core_payment\form\account_gateway
$form): void
;
51 * Validates the gateway configuration form.
53 * Needs to be overridden to make sure the incomplete configuration can not be enabled.
55 * @param \core_payment\form\account_gateway $form
56 * @param \stdClass $data
58 * @param array $errors form errors (passed by reference)
60 public static function validate_gateway_form(\core_payment\form\account_gateway
$form,
61 \stdClass
$data, array $files, array &$errors): void
{
63 $errors['enabled'] = get_string('gatewaycannotbeenabled', 'payment');