* @return string
*/
public function get_section_title() {
- return get_string('type_pg_plural', 'plugin');
+ return get_string('type_paygw_plural', 'plugin');
}
/**
* @return string
*/
public function get_plugin_type() {
- return 'pg';
+ return 'paygw';
}
/**
}
// Payment gateway plugins.
- $ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_pg_plural', 'plugin')));
- $temp = new admin_settingpage('managepaymentgateways', new lang_string('type_pgmanage', 'plugin'));
+ $ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_paygw_plural', 'plugin')));
+ $temp = new admin_settingpage('managepaymentgateways', new lang_string('type_paygwmanage', 'plugin'));
$temp->add(new \core_admin\local\settings\manage_payment_gateway_plugins());
$temp->add(new admin_setting_description(
'managepaymentgatewayspostfix',
));
$ADMIN->add('paymentgateways', $temp);
- $plugins = core_plugin_manager::instance()->get_plugins_of_type('pg');
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('paygw');
core_collator::asort_objects_by_property($plugins, 'displayname');
foreach ($plugins as $plugin) {
- /** @var \core\plugininfo\pg $plugin */
+ /** @var \core\plugininfo\paygw $plugin */
$plugin->load_settings($ADMIN, 'paymentgateways', $hassiteconfig);
}
$string['type_mnetservice_plural'] = 'MNet services';
$string['type_mod'] = 'Activity module';
$string['type_mod_plural'] = 'Activity modules';
-$string['type_pgmanage'] = 'Manage payment gateways';
-$string['type_pg'] = 'Payment gateway';
-$string['type_pg_plural'] = 'Payment gateways';
+$string['type_paygwmanage'] = 'Manage payment gateways';
+$string['type_paygw'] = 'Payment gateway';
+$string['type_paygw_plural'] = 'Payment gateways';
$string['type_plagiarism'] = 'Plagiarism plugin';
$string['type_plagiarism_plural'] = 'Plagiarism plugins';
$string['type_portfolio'] = 'Portfolio';
'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop'
),
- 'pg' => [
+ 'paygw' => [
'paypal',
],
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class pg extends base {
+class paygw extends base {
public function is_uninstall_allowed() {
return true;
}
public static function get_enabled_plugins() {
global $CFG;
- $order = (!empty($CFG->pg_plugins_sortorder)) ? explode(',', $CFG->pg_plugins_sortorder) : [];
+ $order = (!empty($CFG->paygw_plugins_sortorder)) ? explode(',', $CFG->paygw_plugins_sortorder) : [];
if ($order) {
- $plugins = \core_plugin_manager::instance()->get_installed_plugins('pg');
+ $plugins = \core_plugin_manager::instance()->get_installed_plugins('paygw');
$order = array_intersect($order, array_keys($plugins));
}
}
if ($newstate) {
// Enable gateway plugin.
- $plugins = \core_plugin_manager::instance()->get_plugins_of_type('pg');
+ $plugins = \core_plugin_manager::instance()->get_plugins_of_type('paygw');
if (!array_key_exists($this->name, $plugins)) {
// Can not be enabled.
return;
$list = explode(',', $list);
}
if ($list) {
- $plugins = \core_plugin_manager::instance()->get_installed_plugins('pg');
+ $plugins = \core_plugin_manager::instance()->get_installed_plugins('paygw');
$list = array_intersect($list, array_keys($plugins));
}
- set_config('pg_plugins_sortorder', join(',', $list));
+ set_config('paygw_plugins_sortorder', join(',', $list));
\core_plugin_manager::reset_caches();
}
* @return string[] An array of the currency codes in the three-character ISO-4217 format
*/
public function get_supported_currencies(): array {
- $classname = '\pg_'.$this->name.'\gateway';
+ $classname = '\paygw_'.$this->name.'\gateway';
return $classname::get_supported_currencies();
}
"theme": "theme",
"local": "local",
"h5plib": "h5p\/h5plib",
- "pg": "payment\/gateway"
+ "paygw": "payment\/gateway"
},
"subsystems": {
"access": null,
admin_externalpage_setup('paymentaccounts');
$PAGE->set_heading(get_string('paymentaccounts', 'payment'));
-$enabledplugins = \core\plugininfo\pg::get_enabled_plugins();
+$enabledplugins = \core\plugininfo\paygw::get_enabled_plugins();
echo $OUTPUT->header();
$accounts = \core_payment\helper::get_payment_accounts_to_manage(context_system::instance(), $showarchived);
$table = new html_table();
-$table->head = [get_string('accountname', 'payment'), get_string('type_pg_plural', 'plugin'), ''];
+$table->head = [get_string('accountname', 'payment'), get_string('type_paygw_plural', 'plugin'), ''];
$table->colclasses = ['', '', 'mdl-right'];
$table->data = [];
foreach ($accounts as $account) {
if (has_capability('moodle/site:config', context_system::instance())) {
// For administrators add a link to "Manage payment gateways" page.
$link = html_writer::link(new moodle_url('/admin/settings.php', ['section' => 'managepaymentgateways']),
- get_string('type_pgmanage', 'plugin'));
+ get_string('type_paygwmanage', 'plugin'));
$text = get_string('gotomanageplugins', 'payment', $link);
echo html_writer::div($text, 'pb-2');
}
* @returns {Promise<void>}
*/
const processPayment = async(gateway, component, paymentArea, componentId, description, callback) => {
- const paymentMethod = await import(`pg_${gateway}/gateways_modal`);
+ const paymentMethod = await import(`paygw_${gateway}/gateways_modal`);
paymentMethod.process(component, paymentArea, componentId, description, callback);
};
return [];
}
if ($this->gateways === null) {
- \core_component::get_plugin_list('pg');
+ \core_component::get_plugin_list('paygw');
$this->gateways = [];
- foreach (\core_component::get_plugin_list('pg') as $gatewayname => $unused) {
+ foreach (\core_component::get_plugin_list('paygw') as $gatewayname => $unused) {
$gateway = account_gateway::get_record(['accountid' => $id, 'gateway' => $gatewayname]);
if (!$gateway) {
$gateway = new account_gateway(0, (object)['accountid' => $id, 'gateway' => $gatewayname,
}
}
if ($enabledpluginsonly) {
- $enabledplugins = \core\plugininfo\pg::get_enabled_plugins();
+ $enabledplugins = \core\plugininfo\paygw::get_enabled_plugins();
return array_intersect_key($this->gateways, $enabledplugins);
}
return $this->gateways;
* @return string
*/
public function get_display_name(): string {
- return get_string('pluginname', 'pg_' . $this->get('gateway'));
+ return get_string('pluginname', 'paygw_' . $this->get('gateway'));
}
/**
$surcharge = helper::get_gateway_surcharge($gateway);
$list[] = (object)[
'shortname' => $gateway,
- 'name' => get_string('gatewayname', 'pg_' . $gateway),
- 'description' => get_string('gatewaydescription', 'pg_' . $gateway),
+ 'name' => get_string('gatewayname', 'paygw_' . $gateway),
+ 'description' => get_string('gatewaydescription', 'paygw_' . $gateway),
'surcharge' => $surcharge,
'cost' => helper::get_cost_as_string($amount, $currency, $surcharge),
];
$mform->addElement('static', 'accountname', get_string('accountname', 'payment'),
$this->get_gateway_persistent()->get_account()->get_formatted_name());
- $mform->addElement('static', 'gatewayname', get_string('type_pg', 'plugin'),
+ $mform->addElement('static', 'gatewayname', get_string('type_paygw', 'plugin'),
$this->get_gateway_persistent()->get_display_name());
$mform->addElement('advcheckbox', 'enabled', get_string('enable'));
/** @var \core_payment\gateway $classname */
- $classname = '\pg_' . $this->get_gateway_persistent()->get('gateway') . '\gateway';
+ $classname = '\paygw_' . $this->get_gateway_persistent()->get('gateway') . '\gateway';
if (class_exists($classname)) {
$classname::add_configuration_to_gateway_form($this);
}
*/
protected function extra_validation($data, $files, array &$errors) {
/** @var \core_payment\gateway $classname */
- $classname = '\pg_' . $this->get_gateway_persistent()->get('gateway') . '\gateway';
+ $classname = '\paygw_' . $this->get_gateway_persistent()->get('gateway') . '\gateway';
if (class_exists($classname)) {
$classname::validate_gateway_form($this, $data, $files, $errors);
}
public static function get_supported_currencies(): array {
$currencies = [];
- $plugins = \core_plugin_manager::instance()->get_enabled_plugins('pg');
+ $plugins = \core_plugin_manager::instance()->get_enabled_plugins('paygw');
foreach ($plugins as $plugin) {
- /** @var \pg_paypal\gateway $classname */
- $classname = '\pg_' . $plugin . '\gateway';
+ /** @var \paygw_paypal\gateway $classname */
+ $classname = '\paygw_' . $plugin . '\gateway';
$currencies += component_class_callback($classname, 'get_supported_currencies', [], []);
}
continue;
}
/** @var gateway $classname */
- $classname = '\pg_' . $plugin . '\gateway';
+ $classname = '\paygw_' . $plugin . '\gateway';
$currencies = component_class_callback($classname, 'get_supported_currencies', [], []);
if (in_array($currency, $currencies)) {
* @return float
*/
public static function get_gateway_surcharge(string $gateway): float {
- return (float)get_config('pg_' . $gateway, 'surcharge');
+ return (float)get_config('paygw_' . $gateway, 'surcharge');
}
/**
* This functions adds the settings that are common for all payment gateways.
*
* @param \admin_settingpage $settings The settings object
- * @param string $gateway The gateway name prefic with pg_
+ * @param string $gateway The gateway name prefixed with paygw_
*/
public static function add_common_gateway_settings(\admin_settingpage $settings, string $gateway): void {
$settings->add(new \admin_setting_configtext($gateway . '/surcharge', get_string('surcharge', 'core_payment'),
/**
* This module is responsible for PayPal content in the gateways modal.
*
- * @module pg_paypal/gateway_modal
+ * @module paygw_paypal/gateway_modal
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/
const showModalWithPlaceholder = async() => {
const modal = await ModalFactory.create({
- body: await Templates.render('pg_paypal/paypal_button_placeholder', {})
+ body: await Templates.render('paygw_paypal/paypal_button_placeholder', {})
});
modal.show();
return modal;
e.preventDefault();
});
- modal.setBody(getString('authorising', 'pg_paypal'));
+ modal.setBody(getString('authorising', 'paygw_paypal'));
// Call server to validate and capture payment for order.
return Ajax.call([{
- methodname: 'pg_paypal_create_transaction_complete',
+ methodname: 'paygw_paypal_create_transaction_complete',
args: {
component,
paymentarea: paymentArea,
/**
* PayPal repository module to encapsulate all of the AJAX requests that can be sent for PayPal.
*
- * @module pg_paypal/repository
- * @package pg_paypal
+ * @module paygw_paypal/repository
+ * @package paygw_paypal
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/
export const getConfigForJs = (component, paymentArea, componentId) => {
const request = {
- methodname: 'pg_paypal_get_config_for_js',
+ methodname: 'paygw_paypal_get_config_for_js',
args: {
component,
paymentarea: paymentArea,
/**
* This class contains a list of webservice functions related to the PayPal payment gateway.
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
declare(strict_types=1);
-namespace pg_paypal\external;
+namespace paygw_paypal\external;
use core_payment\helper;
use external_api;
/**
* This class contains a list of webservice functions related to the PayPal payment gateway.
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
declare(strict_types=1);
-namespace pg_paypal\external;
+namespace paygw_paypal\external;
use core_payment\helper;
use external_api;
use external_function_parameters;
use external_value;
use core_payment\helper as payment_helper;
-use pg_paypal\paypal_helper;
+use paygw_paypal\paypal_helper;
defined('MOODLE_INTERNAL') || die();
$record->paymentid = $paymentid;
$record->pp_orderid = $orderid;
- $DB->insert_record('pg_paypal', $record);
+ $DB->insert_record('paygw_paypal', $record);
payment_helper::deliver_order($component, $paymentarea, $componentid, $paymentid);
} catch (\Exception $e) {
debugging('Exception while trying to process payment: ' . $e->getMessage(), DEBUG_DEVELOPER);
$success = false;
- $message = get_string('internalerror', 'pg_paypal');
+ $message = get_string('internalerror', 'paygw_paypal');
}
} else {
$success = false;
- $message = get_string('paymentnotcleared', 'pg_paypal');
+ $message = get_string('paymentnotcleared', 'paygw_paypal');
}
} else {
$success = false;
- $message = get_string('amountmismatch', 'pg_paypal');
+ $message = get_string('amountmismatch', 'paygw_paypal');
}
} else {
$success = false;
- $message = get_string('paymentnotcleared', 'pg_paypal');
+ $message = get_string('paymentnotcleared', 'paygw_paypal');
}
} else {
// Could not capture authorization!
$success = false;
- $message = get_string('cannotfetchorderdatails', 'pg_paypal');
+ $message = get_string('cannotfetchorderdatails', 'paygw_paypal');
}
return [
/**
* Contains class for PayPal payment gateway.
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-namespace pg_paypal;
+namespace paygw_paypal;
defined('MOODLE_INTERNAL') || die();
public static function add_configuration_to_gateway_form(\core_payment\form\account_gateway $form): void {
$mform = $form->get_mform();
- $mform->addElement('text', 'brandname', get_string('brandname', 'pg_paypal'));
+ $mform->addElement('text', 'brandname', get_string('brandname', 'paygw_paypal'));
$mform->setType('brandname', PARAM_TEXT);
- $mform->addHelpButton('brandname', 'brandname', 'pg_paypal');
+ $mform->addHelpButton('brandname', 'brandname', 'paygw_paypal');
- $mform->addElement('text', 'clientid', get_string('clientid', 'pg_paypal'));
+ $mform->addElement('text', 'clientid', get_string('clientid', 'paygw_paypal'));
$mform->setType('clientid', PARAM_TEXT);
- $mform->addHelpButton('clientid', 'clientid', 'pg_paypal');
+ $mform->addHelpButton('clientid', 'clientid', 'paygw_paypal');
- $mform->addElement('text', 'secret', get_string('secret', 'pg_paypal'));
+ $mform->addElement('text', 'secret', get_string('secret', 'paygw_paypal'));
$mform->setType('secret', PARAM_TEXT);
- $mform->addHelpButton('secret', 'secret', 'pg_paypal');
+ $mform->addHelpButton('secret', 'secret', 'paygw_paypal');
$options = [
- 'live' => get_string('live', 'pg_paypal'),
- 'sandbox' => get_string('sandbox', 'pg_paypal'),
+ 'live' => get_string('live', 'paygw_paypal'),
+ 'sandbox' => get_string('sandbox', 'paygw_paypal'),
];
- $mform->addElement('select', 'environment', get_string('environment', 'pg_paypal'), $options);
- $mform->addHelpButton('environment', 'environment', 'pg_paypal');
+ $mform->addElement('select', 'environment', get_string('environment', 'paygw_paypal'), $options);
+ $mform->addHelpButton('environment', 'environment', 'paygw_paypal');
}
/**
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-namespace pg_paypal;
+namespace paygw_paypal;
use curl;
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * pg_paypal installer script.
+ * paygw_paypal installer script.
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2020 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-function xmldb_pg_paypal_install() {
+function xmldb_paygw_paypal_install() {
// Enable the Paypal payment gateway on installation. It still needs to be configured and enabled for accounts.
- $order = (!empty($CFG->pg_plugins_sortorder)) ? explode(',', $CFG->pg_plugins_sortorder) : [];
- set_config('pg_plugins_sortorder', join(',', array_merge($order, ['paypal'])));
+ $order = (!empty($CFG->paygw_plugins_sortorder)) ? explode(',', $CFG->paygw_plugins_sortorder) : [];
+ set_config('paygw_plugins_sortorder', join(',', array_merge($order, ['paypal'])));
}
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
- <TABLE NAME="pg_paypal" COMMENT="Stores PayPal related information">
+ <TABLE NAME="paygw_paypal" COMMENT="Stores PayPal related information">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="paymentid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
/**
* External functions and service definitions for the PayPal payment gateway plugin.
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$functions = [
- 'pg_paypal_get_config_for_js' => [
- 'classname' => 'pg_paypal\external\get_config_for_js',
+ 'paygw_paypal_get_config_for_js' => [
+ 'classname' => 'paygw_paypal\external\get_config_for_js',
'methodname' => 'execute',
'classpath' => '',
'description' => 'Returns the configuration settings to be used in js',
'type' => 'read',
'ajax' => true,
],
- 'pg_paypal_create_transaction_complete' => [
- 'classname' => 'pg_paypal\external\transaction_complete',
+ 'paygw_paypal_create_transaction_complete' => [
+ 'classname' => 'paygw_paypal\external\transaction_complete',
'methodname' => 'execute',
'classpath' => '',
'description' => 'Takes care of what needs to be done when a PayPal transaction comes back as complete.',
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Strings for component 'pg_paypal', language 'en'
+ * Strings for component 'paygw_paypal', language 'en'
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Settings for the PayPal payment gateway
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if ($ADMIN->fulltree) {
- $settings->add(new admin_setting_heading('pg_paypal_settings', '', get_string('pluginname_desc', 'pg_paypal')));
+ $settings->add(new admin_setting_heading('paygw_paypal_settings', '', get_string('pluginname_desc', 'paygw_paypal')));
- \core_payment\helper::add_common_gateway_settings($settings, 'pg_paypal');
+ \core_payment\helper::add_common_gateway_settings($settings, 'paygw_paypal');
}
/**
* Version information
*
- * @package pg_paypal
+ * @package paygw_paypal
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$plugin->version = 2020102700; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2020060900; // Requires this Moodle version.
-$plugin->component = 'pg_paypal'; // Full name of the plugin (used for diagnostics).
+$plugin->component = 'paygw_paypal'; // Full name of the plugin (used for diagnostics).
$pageurl = new moodle_url('/payment/manage_account.php');
admin_externalpage_setup('paymentaccounts', '', [], $pageurl);
-$enabledplugins = \core\plugininfo\pg::get_enabled_plugins();
+$enabledplugins = \core\plugininfo\paygw::get_enabled_plugins();
$account = new \core_payment\account($id);
require_capability('moodle/payment:manageaccounts', $account->get_context());
$pageurl = new moodle_url('/payment/manage_gateway.php');
admin_externalpage_setup('paymentaccounts', '', [], $pageurl);
-$enabledplugins = \core\plugininfo\pg::get_enabled_plugins();
+$enabledplugins = \core\plugininfo\paygw::get_enabled_plugins();
if ($id) {
$gateway = new \core_payment\account_gateway($id);
<label class="custom-control-label bg-light border p-3 my-3" for="id-payby-{{uniqid}}-{{shortname}}">
<p class="h3">{{name}}</p>
<p class="content mb-2">{{description}}</p>
- {{#pix}} img, pg_{{shortname}} {{/pix}}
+ {{#pix}} img, paygw_{{shortname}} {{/pix}}
</label>
</div>
\ No newline at end of file
throw new coding_exception('Amount must be specified');
}
- $gateways = \core\plugininfo\pg::get_enabled_plugins();
+ $gateways = \core\plugininfo\paygw::get_enabled_plugins();
if (empty($data['gateway'])) {
$data['gateway'] = reset($gateways);
}
namespace core_payment;
use advanced_testcase;
-use core\plugininfo\pg;
+use core\plugininfo\paygw;
/**
* Testing helper class methods in payments API
class accounts_testcase extends advanced_testcase {
protected function enable_paypal_gateway(): bool {
- if (!array_key_exists('paypal', \core_component::get_plugin_list('pg'))) {
+ if (!array_key_exists('paypal', \core_component::get_plugin_list('paygw'))) {
return false;
}
return true;