MDL-69166 core_payment: Renamed plugintype name from pg to paygw
authorShamim Rezaie <shamim@moodle.com>
Fri, 16 Oct 2020 15:45:36 +0000 (02:45 +1100)
committerShamim Rezaie <shamim@moodle.com>
Tue, 27 Oct 2020 04:34:55 +0000 (15:34 +1100)
36 files changed:
admin/classes/local/settings/manage_payment_gateway_plugins.php
admin/settings/plugins.php
lang/en/plugin.php
lib/classes/plugin_manager.php
lib/classes/plugininfo/paygw.php [moved from lib/classes/plugininfo/pg.php with 93% similarity]
lib/components.json
payment/accounts.php
payment/amd/build/gateways_modal.min.js
payment/amd/build/gateways_modal.min.js.map
payment/amd/src/gateways_modal.js
payment/classes/account.php
payment/classes/account_gateway.php
payment/classes/external/get_available_gateways.php
payment/classes/form/account_gateway.php
payment/classes/helper.php
payment/gateway/paypal/amd/build/gateways_modal.min.js
payment/gateway/paypal/amd/build/gateways_modal.min.js.map
payment/gateway/paypal/amd/build/repository.min.js
payment/gateway/paypal/amd/build/repository.min.js.map
payment/gateway/paypal/amd/src/gateways_modal.js
payment/gateway/paypal/amd/src/repository.js
payment/gateway/paypal/classes/external/get_config_for_js.php
payment/gateway/paypal/classes/external/transaction_complete.php
payment/gateway/paypal/classes/gateway.php
payment/gateway/paypal/classes/paypal_helper.php
payment/gateway/paypal/db/install.php
payment/gateway/paypal/db/install.xml
payment/gateway/paypal/db/services.php
payment/gateway/paypal/lang/en/paygw_paypal.php [moved from payment/gateway/paypal/lang/en/pg_paypal.php with 96% similarity]
payment/gateway/paypal/settings.php
payment/gateway/paypal/version.php
payment/manage_account.php
payment/manage_gateway.php
payment/templates/gateway.mustache
payment/tests/generator/lib.php
payment/tests/helper_test.php

index eb97b47..f61951c 100644 (file)
@@ -34,7 +34,7 @@ class manage_payment_gateway_plugins extends \admin_setting_manage_plugins {
      * @return string
      */
     public function get_section_title() {
-        return get_string('type_pg_plural', 'plugin');
+        return get_string('type_paygw_plural', 'plugin');
     }
 
     /**
@@ -43,7 +43,7 @@ class manage_payment_gateway_plugins extends \admin_setting_manage_plugins {
      * @return string
      */
     public function get_plugin_type() {
-        return 'pg';
+        return 'paygw';
     }
 
     /**
index 5bd2e2f..8def3d7 100644 (file)
@@ -281,8 +281,8 @@ if ($hassiteconfig) {
     }
 
     // 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',
@@ -292,10 +292,10 @@ if ($hassiteconfig) {
     ));
     $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);
     }
 
index 05e19ff..d25ee12 100644 (file)
@@ -165,9 +165,9 @@ $string['type_mnetservice'] = 'MNet service';
 $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';
index 36392ce..0ec1070 100644 (file)
@@ -1923,7 +1923,7 @@ class core_plugin_manager {
                 'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop'
             ),
 
-            'pg' => [
+            'paygw' => [
                 'paypal',
             ],
 
similarity index 93%
rename from lib/classes/plugininfo/pg.php
rename to lib/classes/plugininfo/paygw.php
index 5aab880..35c6beb 100644 (file)
@@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
  * @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;
     }
@@ -73,9 +73,9 @@ class pg extends base {
     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));
         }
 
@@ -96,7 +96,7 @@ class pg extends base {
         }
         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;
@@ -123,10 +123,10 @@ class pg extends base {
             $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();
     }
 
@@ -136,7 +136,7 @@ class pg extends base {
      * @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();
     }
index 4ed59e8..3d9dfc9 100644 (file)
@@ -39,7 +39,7 @@
         "theme": "theme",
         "local": "local",
         "h5plib": "h5p\/h5plib",
-        "pg": "payment\/gateway"
+        "paygw": "payment\/gateway"
     },
     "subsystems": {
         "access": null,
index 122ad43..012b2b9 100644 (file)
@@ -30,13 +30,13 @@ $showarchived = optional_param('showarchived', false, PARAM_BOOL);
 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) {
@@ -79,7 +79,7 @@ echo html_writer::div(get_string('paymentaccountsexplained', 'payment'), 'pb-2')
 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');
 }
index 8bd0a55..32d97f4 100644 (file)
Binary files a/payment/amd/build/gateways_modal.min.js and b/payment/amd/build/gateways_modal.min.js differ
index 7c6c31a..84a00d7 100644 (file)
Binary files a/payment/amd/build/gateways_modal.min.js.map and b/payment/amd/build/gateways_modal.min.js.map differ
index ad64845..cf74851 100644 (file)
@@ -180,7 +180,7 @@ const updateCostRegion = async(root, defaultCost = '') => {
  * @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);
 };
 
index 7a03b4b..9b703c8 100644 (file)
@@ -118,9 +118,9 @@ class account extends persistent {
             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,
@@ -130,7 +130,7 @@ class account extends persistent {
             }
         }
         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;
index c97007b..3df6c4f 100644 (file)
@@ -71,7 +71,7 @@ class account_gateway extends persistent {
      * @return string
      */
     public function get_display_name(): string {
-        return get_string('pluginname', 'pg_' . $this->get('gateway'));
+        return get_string('pluginname', 'paygw_' . $this->get('gateway'));
     }
 
     /**
index 9e3d432..3eba964 100644 (file)
@@ -77,8 +77,8 @@ class get_available_gateways extends external_api {
             $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),
             ];
index 575cf02..b4c03b7 100644 (file)
@@ -53,13 +53,13 @@ class account_gateway extends persistent {
         $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);
         }
@@ -76,7 +76,7 @@ class account_gateway extends persistent {
      */
     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);
         }
index 902baf0..4dd64e9 100644 (file)
@@ -44,10 +44,10 @@ class helper {
     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', [], []);
         }
@@ -83,7 +83,7 @@ class helper {
                 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)) {
@@ -137,7 +137,7 @@ class helper {
      * @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');
     }
 
     /**
@@ -270,7 +270,7 @@ class helper {
      * 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'),
index ddeb503..08f064c 100644 (file)
Binary files a/payment/gateway/paypal/amd/build/gateways_modal.min.js and b/payment/gateway/paypal/amd/build/gateways_modal.min.js differ
index afd4b9d..343c7df 100644 (file)
Binary files a/payment/gateway/paypal/amd/build/gateways_modal.min.js.map and b/payment/gateway/paypal/amd/build/gateways_modal.min.js.map differ
index d0cc2e9..af79a9e 100644 (file)
Binary files a/payment/gateway/paypal/amd/build/repository.min.js and b/payment/gateway/paypal/amd/build/repository.min.js differ
index 0c7f8d1..af94441 100644 (file)
Binary files a/payment/gateway/paypal/amd/build/repository.min.js.map and b/payment/gateway/paypal/amd/build/repository.min.js.map differ
index 9858b63..59f4bb1 100644 (file)
@@ -16,7 +16,7 @@
 /**
  * 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
  */
@@ -36,7 +36,7 @@ import {get_string as getString} from 'core/str';
  */
 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;
@@ -98,11 +98,11 @@ export const process = async(component, paymentArea, componentId, description, c
                     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,
index 50cfc41..627c95d 100644 (file)
@@ -16,8 +16,8 @@
 /**
  * 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
  */
@@ -34,7 +34,7 @@ import Ajax from 'core/ajax';
  */
 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,
index bf6ccc6..0cd110f 100644 (file)
 /**
  * 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;
index 2a89528..251272d 100644 (file)
 /**
  * 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();
 
@@ -110,30 +110,30 @@ class transaction_complete extends external_api {
                             $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 [
index 438cef6..42519db 100644 (file)
 /**
  * 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();
 
@@ -52,25 +52,25 @@ class gateway extends \core_payment\gateway {
     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');
     }
 
     /**
index ff3409a..a2395f4 100644 (file)
@@ -22,7 +22,7 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-namespace pg_paypal;
+namespace paygw_paypal;
 
 use curl;
 
index a6be0d7..f9ca2d6 100644 (file)
 // 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'])));
 }
index 808f99e..cd145ce 100755 (executable)
@@ -4,7 +4,7 @@
     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"/>
index 9e6d9a7..f1986c6 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * 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.',
@@ -15,9 +15,9 @@
 // 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
  */
index 92ddb89..adbe251 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * 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
  */
@@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die();
 
 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');
 }
index 2ff3fad..e0e23ba 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * 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
  */
@@ -26,4 +26,4 @@ defined('MOODLE_INTERNAL') || die();
 
 $plugin->version   = 2021052500;        // The current plugin version (Date: YYYYMMDDXX).
 $plugin->requires  = 2021052500;        // 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).
index 2d92e6c..d5d2e26 100644 (file)
@@ -32,7 +32,7 @@ $restore = optional_param('restore', false, PARAM_BOOL);
 $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());
index 2833d2c..2a6c21d 100644 (file)
@@ -32,7 +32,7 @@ $gatewayname = optional_param('gateway', null, PARAM_COMPONENT);
 $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);
index bc03694..4189f9f 100644 (file)
@@ -46,6 +46,6 @@
     <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
index 2ccf5b4..48f4649 100644 (file)
@@ -64,7 +64,7 @@ class core_payment_generator extends component_generator_base {
             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);
         }
index 98ef3dd..4177650 100644 (file)
@@ -26,7 +26,7 @@
 namespace core_payment;
 
 use advanced_testcase;
-use core\plugininfo\pg;
+use core\plugininfo\paygw;
 
 /**
  * Testing helper class methods in payments API
@@ -39,7 +39,7 @@ use core\plugininfo\pg;
 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;