diff --git a/admin/classes/local/settings/manage_payment_gateway_plugins.php b/admin/classes/local/settings/manage_payment_gateway_plugins.php index eb97b47efe3..f61951c5f74 100644 --- a/admin/classes/local/settings/manage_payment_gateway_plugins.php +++ b/admin/classes/local/settings/manage_payment_gateway_plugins.php @@ -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'; } /** diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index 5bd2e2ff449..8def3d77223 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -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); } diff --git a/lang/en/plugin.php b/lang/en/plugin.php index 05e19ffa855..d25ee128348 100644 --- a/lang/en/plugin.php +++ b/lang/en/plugin.php @@ -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'; diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 36392ce5728..0ec107057f3 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1923,7 +1923,7 @@ class core_plugin_manager { 'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop' ), - 'pg' => [ + 'paygw' => [ 'paypal', ], diff --git a/lib/classes/plugininfo/pg.php b/lib/classes/plugininfo/paygw.php similarity index 93% rename from lib/classes/plugininfo/pg.php rename to lib/classes/plugininfo/paygw.php index 5aab880d32c..35c6bebf874 100644 --- a/lib/classes/plugininfo/pg.php +++ b/lib/classes/plugininfo/paygw.php @@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2019 Shamim Rezaie * @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(); } diff --git a/lib/components.json b/lib/components.json index 4ed59e8012a..3d9dfc93064 100644 --- a/lib/components.json +++ b/lib/components.json @@ -39,7 +39,7 @@ "theme": "theme", "local": "local", "h5plib": "h5p\/h5plib", - "pg": "payment\/gateway" + "paygw": "payment\/gateway" }, "subsystems": { "access": null, diff --git a/payment/accounts.php b/payment/accounts.php index 122ad43a71e..012b2b9decb 100644 --- a/payment/accounts.php +++ b/payment/accounts.php @@ -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'); } diff --git a/payment/amd/build/gateways_modal.min.js b/payment/amd/build/gateways_modal.min.js index 8bd0a55dc0c..32d97f4155c 100644 --- a/payment/amd/build/gateways_modal.min.js +++ b/payment/amd/build/gateways_modal.min.js @@ -1,2 +1,2 @@ -define ("core_payment/gateways_modal",["exports","core/modal_factory","core/templates","core/str","./repository","./selectors","core/modal_events","core_payment/events","core/toast","core/notification","./modal_gateways"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.registerEventListeners=a.registerEventListenersBySelector=void 0;b=l(b);c=l(c);f=l(f);g=l(g);h=l(h);j=l(j);k=l(k);var o="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function l(a){return a&&a.__esModule?a:{default:a}}function m(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function n(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){m(h,d,e,f,g,"next",a)}function g(a){m(h,d,e,f,g,"throw",a)}f(void 0)})}}a.registerEventListenersBySelector=function registerEventListenersBySelector(a){document.querySelectorAll(a).forEach(function(a){p(a)})};var p=function(a){a.addEventListener("click",function(b){b.preventDefault();q(a,{focusOnClose:b.target})})};a.registerEventListeners=p;var q=function(){var a=n(regeneratorRuntime.mark(function a(l){var m,n,o,p,q,u,v,w,x,y,z=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:m=1.\n\n/**\n * Contain the logic for the gateways modal.\n *\n * @module core_payment/gateways_modal\n * @package core_payment\n * @copyright 2019 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalFactory from 'core/modal_factory';\nimport Templates from 'core/templates';\nimport {get_string as getString} from 'core/str';\nimport {getAvailableGateways} from './repository';\nimport Selectors from './selectors';\nimport ModalEvents from 'core/modal_events';\nimport PaymentEvents from 'core_payment/events';\nimport {add as addToast, addToastRegion} from 'core/toast';\nimport Notification from 'core/notification';\nimport ModalGateways from './modal_gateways';\n\n/**\n * Register event listeners for the module.\n *\n * @param {string} nodeSelector The root to listen to.\n */\nexport const registerEventListenersBySelector = (nodeSelector) => {\n document.querySelectorAll(nodeSelector).forEach((element) => {\n registerEventListeners(element);\n });\n};\n\n/**\n * Register event listeners for the module.\n *\n * @param {HTMLElement} rootNode The root to listen to.\n */\nexport const registerEventListeners = (rootNode) => {\n rootNode.addEventListener('click', (e) => {\n e.preventDefault();\n show(rootNode, {focusOnClose: e.target});\n });\n};\n\n/**\n * Shows the gateway selector modal.\n *\n * @param {HTMLElement} rootNode\n * @param {Object} options - Additional options\n * @param {HTMLElement} options.focusOnClose The element to focus on when the modal is closed.\n */\nconst show = async(rootNode, {\n focusOnClose = null,\n} = {}) => {\n const modal = await ModalFactory.create({\n type: ModalGateways.TYPE,\n title: await getString('selectpaymenttype', 'core_payment'),\n body: await Templates.render('core_payment/gateways_modal', {}),\n });\n\n const rootElement = modal.getRoot()[0];\n addToastRegion(rootElement);\n\n modal.show();\n\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Destroy when hidden.\n modal.destroy();\n try {\n focusOnClose.focus();\n } catch (e) {\n // eslint-disable-line\n }\n });\n\n modal.getRoot().on(PaymentEvents.proceed, (e) => {\n const gateway = (rootElement.querySelector(Selectors.values.gateway) || {value: ''}).value;\n\n if (gateway) {\n processPayment(\n gateway,\n rootNode.dataset.component,\n rootNode.dataset.paymentarea,\n rootNode.dataset.componentid,\n rootNode.dataset.description,\n ({success, message = ''}) => {\n modal.hide();\n if (success) {\n Notification.addNotification({\n message: message,\n type: 'success',\n });\n location.reload();\n } else {\n Notification.alert('', message);\n }\n },\n );\n } else {\n // We cannot use await in the following line.\n // The reason is that we are preventing the default action of the save event being triggered,\n // therefore we cannot define the event handler function asynchronous.\n getString('nogatewayselected', 'core_payment').then(message => addToast(message));\n }\n\n e.preventDefault();\n });\n\n // Re-calculate the cost when gateway is changed.\n rootElement.addEventListener('change', e => {\n if (e.target.matches(Selectors.elements.gateways)) {\n updateCostRegion(rootElement, rootNode.dataset.cost);\n }\n });\n\n const gateways = await getAvailableGateways(rootNode.dataset.component, rootNode.dataset.paymentarea,\n rootNode.dataset.componentid);\n const context = {\n gateways\n };\n\n const {html, js} = await Templates.renderForPromise('core_payment/gateways', context);\n Templates.replaceNodeContents(rootElement.querySelector(Selectors.regions.gatewaysContainer), html, js);\n selectSingleGateway(rootElement);\n await updateCostRegion(rootElement, rootNode.dataset.cost);\n};\n\n/**\n * Auto-select the gateway if there is only one gateway.\n *\n * @param {HTMLElement} root An HTMLElement that contains the cost region\n */\nconst selectSingleGateway = root => {\n const gateways = root.querySelectorAll(Selectors.elements.gateways);\n\n if (gateways.length == 1) {\n gateways[0].checked = true;\n }\n};\n\n/**\n * Shows the cost of the item the user is purchasing in the cost region.\n *\n * @param {HTMLElement} root An HTMLElement that contains the cost region\n * @param {string} defaultCost The default cost that is going to be displayed if no gateway is selected\n * @returns {Promise}\n */\nconst updateCostRegion = async(root, defaultCost = '') => {\n const gatewayElement = root.querySelector(Selectors.values.gateway);\n const surcharge = parseInt((gatewayElement || {dataset: {surcharge: 0}}).dataset.surcharge);\n const cost = (gatewayElement || {dataset: {cost: defaultCost}}).dataset.cost;\n\n const {html, js} = await Templates.renderForPromise('core_payment/fee_breakdown', {fee: cost, surcharge});\n Templates.replaceNodeContents(root.querySelector(Selectors.regions.costContainer), html, js);\n};\n\n/**\n * Process payment using the selected gateway.\n *\n * @param {string} gateway The gateway to be used for payment\n * @param {string} component Name of the component that the componentId belongs to\n * @param {string} paymentArea Name of the area in the component that the componentId belongs to\n * @param {number} componentId An internal identifier that is used by the component\n * @param {string} description Description of the payment\n * @param {processPaymentCallback} callback The callback function to call when processing is finished\n * @returns {Promise}\n */\nconst processPayment = async(gateway, component, paymentArea, componentId, description, callback) => {\n const paymentMethod = await import(`pg_${gateway}/gateways_modal`);\n paymentMethod.process(component, paymentArea, componentId, description, callback);\n};\n\n/**\n * The callback definition for processPayment.\n *\n * @callback processPaymentCallback\n * @param {bool} success\n * @param {string} message\n */\n"],"file":"gateways_modal.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/gateways_modal.js"],"names":["registerEventListenersBySelector","nodeSelector","document","querySelectorAll","forEach","element","registerEventListeners","rootNode","addEventListener","e","preventDefault","show","focusOnClose","target","ModalFactory","ModalGateways","TYPE","Templates","render","type","title","body","create","modal","rootElement","getRoot","on","ModalEvents","hidden","destroy","focus","PaymentEvents","proceed","gateway","querySelector","Selectors","values","value","processPayment","dataset","component","paymentarea","componentid","description","success","message","hide","Notification","addNotification","location","reload","alert","then","matches","elements","gateways","updateCostRegion","cost","context","renderForPromise","html","js","replaceNodeContents","regions","gatewaysContainer","selectSingleGateway","root","length","checked","defaultCost","gatewayElement","surcharge","parseInt","fee","costContainer","paymentArea","componentId","callback","paymentMethod","process"],"mappings":"+XAwBA,OACA,OAGA,OACA,OACA,OAEA,OACA,O,ggBAOgD,QAAnCA,CAAAA,gCAAmC,CAACC,CAAD,CAAkB,CAC9DC,QAAQ,CAACC,gBAAT,CAA0BF,CAA1B,EAAwCG,OAAxC,CAAgD,SAACC,CAAD,CAAa,CACzDC,CAAsB,CAACD,CAAD,CACzB,CAFD,CAGH,C,CAOM,GAAMC,CAAAA,CAAsB,CAAG,SAACC,CAAD,CAAc,CAChDA,CAAQ,CAACC,gBAAT,CAA0B,OAA1B,CAAmC,SAACC,CAAD,CA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MACyB5C,CADzB,sOACyBA,CADzB,yDACyBA,CADzB,6BACb6C,CADa,QAEnBA,CAAa,CAACC,OAAd,CAAsBvC,CAAtB,CAAiCmC,CAAjC,CAA8CC,CAA9C,CAA2DjC,CAA3D,CAAwEkC,CAAxE,EAFmB,wCAAH,uD","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the gateways modal.\n *\n * @module core_payment/gateways_modal\n * @package core_payment\n * @copyright 2019 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalFactory from 'core/modal_factory';\nimport Templates from 'core/templates';\nimport {get_string as getString} from 'core/str';\nimport {getAvailableGateways} from './repository';\nimport Selectors from './selectors';\nimport ModalEvents from 'core/modal_events';\nimport PaymentEvents from 'core_payment/events';\nimport {add as addToast, addToastRegion} from 'core/toast';\nimport Notification from 'core/notification';\nimport ModalGateways from './modal_gateways';\n\n/**\n * Register event listeners for the module.\n *\n * @param {string} nodeSelector The root to listen to.\n */\nexport const registerEventListenersBySelector = (nodeSelector) => {\n document.querySelectorAll(nodeSelector).forEach((element) => {\n registerEventListeners(element);\n });\n};\n\n/**\n * Register event listeners for the module.\n *\n * @param {HTMLElement} rootNode The root to listen to.\n */\nexport const registerEventListeners = (rootNode) => {\n rootNode.addEventListener('click', (e) => {\n e.preventDefault();\n show(rootNode, {focusOnClose: e.target});\n });\n};\n\n/**\n * Shows the gateway selector modal.\n *\n * @param {HTMLElement} rootNode\n * @param {Object} options - Additional options\n * @param {HTMLElement} options.focusOnClose The element to focus on when the modal is closed.\n */\nconst show = async(rootNode, {\n focusOnClose = null,\n} = {}) => {\n const modal = await ModalFactory.create({\n type: ModalGateways.TYPE,\n title: await getString('selectpaymenttype', 'core_payment'),\n body: await Templates.render('core_payment/gateways_modal', {}),\n });\n\n const rootElement = modal.getRoot()[0];\n addToastRegion(rootElement);\n\n modal.show();\n\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Destroy when hidden.\n modal.destroy();\n try {\n focusOnClose.focus();\n } catch (e) {\n // eslint-disable-line\n }\n });\n\n modal.getRoot().on(PaymentEvents.proceed, (e) => {\n const gateway = (rootElement.querySelector(Selectors.values.gateway) || {value: ''}).value;\n\n if (gateway) {\n processPayment(\n gateway,\n rootNode.dataset.component,\n rootNode.dataset.paymentarea,\n rootNode.dataset.componentid,\n rootNode.dataset.description,\n ({success, message = ''}) => {\n modal.hide();\n if (success) {\n Notification.addNotification({\n message: message,\n type: 'success',\n });\n location.reload();\n } else {\n Notification.alert('', message);\n }\n },\n );\n } else {\n // We cannot use await in the following line.\n // The reason is that we are preventing the default action of the save event being triggered,\n // therefore we cannot define the event handler function asynchronous.\n getString('nogatewayselected', 'core_payment').then(message => addToast(message));\n }\n\n e.preventDefault();\n });\n\n // Re-calculate the cost when gateway is changed.\n rootElement.addEventListener('change', e => {\n if (e.target.matches(Selectors.elements.gateways)) {\n updateCostRegion(rootElement, rootNode.dataset.cost);\n }\n });\n\n const gateways = await getAvailableGateways(rootNode.dataset.component, rootNode.dataset.paymentarea,\n rootNode.dataset.componentid);\n const context = {\n gateways\n };\n\n const {html, js} = await Templates.renderForPromise('core_payment/gateways', context);\n Templates.replaceNodeContents(rootElement.querySelector(Selectors.regions.gatewaysContainer), html, js);\n selectSingleGateway(rootElement);\n await updateCostRegion(rootElement, rootNode.dataset.cost);\n};\n\n/**\n * Auto-select the gateway if there is only one gateway.\n *\n * @param {HTMLElement} root An HTMLElement that contains the cost region\n */\nconst selectSingleGateway = root => {\n const gateways = root.querySelectorAll(Selectors.elements.gateways);\n\n if (gateways.length == 1) {\n gateways[0].checked = true;\n }\n};\n\n/**\n * Shows the cost of the item the user is purchasing in the cost region.\n *\n * @param {HTMLElement} root An HTMLElement that contains the cost region\n * @param {string} defaultCost The default cost that is going to be displayed if no gateway is selected\n * @returns {Promise}\n */\nconst updateCostRegion = async(root, defaultCost = '') => {\n const gatewayElement = root.querySelector(Selectors.values.gateway);\n const surcharge = parseInt((gatewayElement || {dataset: {surcharge: 0}}).dataset.surcharge);\n const cost = (gatewayElement || {dataset: {cost: defaultCost}}).dataset.cost;\n\n const {html, js} = await Templates.renderForPromise('core_payment/fee_breakdown', {fee: cost, surcharge});\n Templates.replaceNodeContents(root.querySelector(Selectors.regions.costContainer), html, js);\n};\n\n/**\n * Process payment using the selected gateway.\n *\n * @param {string} gateway The gateway to be used for payment\n * @param {string} component Name of the component that the componentId belongs to\n * @param {string} paymentArea Name of the area in the component that the componentId belongs to\n * @param {number} componentId An internal identifier that is used by the component\n * @param {string} description Description of the payment\n * @param {processPaymentCallback} callback The callback function to call when processing is finished\n * @returns {Promise}\n */\nconst processPayment = async(gateway, component, paymentArea, componentId, description, callback) => {\n const paymentMethod = await import(`paygw_${gateway}/gateways_modal`);\n paymentMethod.process(component, paymentArea, componentId, description, callback);\n};\n\n/**\n * The callback definition for processPayment.\n *\n * @callback processPaymentCallback\n * @param {bool} success\n * @param {string} message\n */\n"],"file":"gateways_modal.min.js"} \ No newline at end of file diff --git a/payment/amd/src/gateways_modal.js b/payment/amd/src/gateways_modal.js index ad6484508fb..cf748516495 100644 --- a/payment/amd/src/gateways_modal.js +++ b/payment/amd/src/gateways_modal.js @@ -180,7 +180,7 @@ const updateCostRegion = async(root, defaultCost = '') => { * @returns {Promise} */ 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); }; diff --git a/payment/classes/account.php b/payment/classes/account.php index 7a03b4b4dae..9b703c8bf0e 100644 --- a/payment/classes/account.php +++ b/payment/classes/account.php @@ -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; diff --git a/payment/classes/account_gateway.php b/payment/classes/account_gateway.php index c97007b4029..3df6c4fe566 100644 --- a/payment/classes/account_gateway.php +++ b/payment/classes/account_gateway.php @@ -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')); } /** diff --git a/payment/classes/external/get_available_gateways.php b/payment/classes/external/get_available_gateways.php index 9e3d432095a..3eba9642953 100644 --- a/payment/classes/external/get_available_gateways.php +++ b/payment/classes/external/get_available_gateways.php @@ -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), ]; diff --git a/payment/classes/form/account_gateway.php b/payment/classes/form/account_gateway.php index 575cf020a03..b4c03b77a27 100644 --- a/payment/classes/form/account_gateway.php +++ b/payment/classes/form/account_gateway.php @@ -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); } diff --git a/payment/classes/helper.php b/payment/classes/helper.php index 902baf0f444..4dd64e9127e 100644 --- a/payment/classes/helper.php +++ b/payment/classes/helper.php @@ -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'), diff --git a/payment/gateway/paypal/amd/build/gateways_modal.min.js b/payment/gateway/paypal/amd/build/gateways_modal.min.js index ddeb503d11b..08f064c9b79 100644 --- a/payment/gateway/paypal/amd/build/gateways_modal.min.js +++ b/payment/gateway/paypal/amd/build/gateways_modal.min.js @@ -1,2 +1,2 @@ -function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("pg_paypal/gateways_modal",["exports","./repository","core/templates","core/truncate","core/ajax","core/modal_factory","core/modal_events","core/str"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.process=void 0;b=k(b);c=i(c);d=i(d);e=i(e);f=i(f);g=i(g);function i(a){return a&&a.__esModule?a:{default:a}}function j(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;j=function(){return a};return a}function k(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=j();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function l(a,b){return r(a)||q(a,b)||n(a,b)||m()}function m(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(a,b){if(!a)return;if("string"==typeof a)return p(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return p(a,b)}function p(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);ca.length)b=a.length;for(var c=0,d=Array(b);c.\n\n/**\n * This module is responsible for PayPal content in the gateways modal.\n *\n * @module pg_paypal/gateway_modal\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport * as Repository from './repository';\nimport Templates from 'core/templates';\nimport Truncate from 'core/truncate';\nimport Ajax from 'core/ajax';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\nimport {get_string as getString} from 'core/str';\n\n/**\n * Creates and shows a modal that contains a placeholder.\n *\n * @returns {Promise}\n */\nconst showModalWithPlaceholder = async() => {\n const modal = await ModalFactory.create({\n body: await Templates.render('pg_paypal/paypal_button_placeholder', {})\n });\n modal.show();\n return modal;\n};\n\n/**\n * Process the payment.\n *\n * @param {string} component Name of the component that the componentId belongs to\n * @param {string} paymentArea The area of the component that the componentId belongs to\n * @param {number} componentId An internal identifier that is used by the component\n * @param {string} description Description of the payment\n * @param {processCallback} callback The callback function to call when processing is finished\n * @returns {Promise}\n */\nexport const process = async(component, paymentArea, componentId, description, callback) => {\n\n const [\n modal,\n paypalConfig,\n ] = await Promise.all([\n showModalWithPlaceholder(),\n Repository.getConfigForJs(component, paymentArea, componentId),\n ]);\n const currency = paypalConfig.currency;\n const amount = paypalConfig.cost; // Cost with surcharge.\n\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Destroy when hidden.\n modal.destroy();\n });\n\n const paypalScript = `https://www.paypal.com/sdk/js?client-id=${paypalConfig.clientid}¤cy=${currency}`;\n\n callExternalFunction(paypalScript, () => {\n modal.setBody(''); // We have to clear the body. The render method in paypal.Buttons will render everything.\n\n paypal.Buttons({ // eslint-disable-line\n // Set up the transaction.\n createOrder: function(data, actions) {\n return actions.order.create({\n purchase_units: [{ // eslint-disable-line\n amount: {\n currency_code: currency, // eslint-disable-line\n value: amount\n },\n description: Truncate.truncate(description, {length: 127, stripTags: true}),\n }],\n application_context: { // eslint-disable-line\n shipping_preference: 'NO_SHIPPING', // eslint-disable-line\n brand_name: Truncate.truncate(paypalConfig.brandname, {length: 127, stripTags: true}), // eslint-disable-line\n },\n });\n },\n // Finalise the transaction.\n onApprove: function(data) {\n modal.getRoot().on(ModalEvents.outsideClick, (e) => {\n // Prevent closing the modal when clicking outside of it.\n e.preventDefault();\n });\n\n modal.setBody(getString('authorising', 'pg_paypal'));\n\n // Call server to validate and capture payment for order.\n return Ajax.call([{\n methodname: 'pg_paypal_create_transaction_complete',\n args: {\n component,\n paymentarea: paymentArea,\n componentid: componentId,\n orderid: data.orderID,\n },\n }])[0]\n .then(function(res) {\n modal.hide();\n return callback(res);\n });\n }\n }).render(modal.getBody()[0]);\n });\n};\n\n/**\n * The callback definition for process.\n *\n * @callback processCallback\n * @param {bool} success\n * @param {string} message\n */\n\n/**\n * Calls a function from an external javascript file.\n *\n * @param {string} jsFile URL of the external JavaScript file\n * @param {function} func The function to call\n */\nconst callExternalFunction = (jsFile, func) => {\n // Check to see if this file has already been loaded. If so just go straight to the func.\n if (callExternalFunction.currentlyloaded == jsFile) {\n func();\n return;\n }\n\n // PayPal can only work with one currency at the same time. We have to unload the previously loaded script\n // if it was loaded for a different currency. Weird way indeed, but the only way.\n // See: https://github.com/paypal/paypal-checkout-components/issues/1180\n if (callExternalFunction.currentlyloaded) {\n const suspectedScript = document.querySelector(`script[src=\"${callExternalFunction.currentlyloaded}\"]`);\n if (suspectedScript) {\n suspectedScript.parentNode.removeChild(suspectedScript);\n }\n }\n\n const script = document.createElement('script');\n\n if (script.readyState) {\n script.onreadystatechange = function() {\n if (this.readyState == 'complete' || this.readyState == 'loaded') {\n this.onreadystatechange = null;\n func();\n }\n };\n } else {\n script.onload = function() {\n func();\n };\n }\n\n script.setAttribute('src', jsFile);\n document.head.appendChild(script);\n\n callExternalFunction.currentlyloaded = jsFile;\n};\n\n/**\n * Holds the full url of loaded external JavaScript file.\n *\n * @static\n * @type {string}\n */\ncallExternalFunction.currentlyloaded = '';\n"],"file":"gateways_modal.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/gateways_modal.js"],"names":["showModalWithPlaceholder","ModalFactory","Templates","render","body","create","modal","show","process","component","paymentArea","componentId","description","callback","Promise","all","Repository","getConfigForJs","paypalConfig","currency","amount","cost","getRoot","on","ModalEvents","hidden","destroy","paypalScript","clientid","callExternalFunction","setBody","paypal","Buttons","createOrder","data","actions","order","purchase_units","currency_code","value","Truncate","truncate","length","stripTags","application_context","shipping_preference","brand_name","brandname","onApprove","outsideClick","e","preventDefault","Ajax","call","methodname","args","paymentarea","componentid","orderid","orderID","then","res","hide","getBody","jsFile","func","currentlyloaded","suspectedScript","document","querySelector","parentNode","removeChild","script","createElement","readyState","onreadystatechange","onload","setAttribute","head","appendChild"],"mappings":"8iBAuBA,OACA,OACA,OACA,OACA,OACA,O,u3DAQMA,CAAAA,CAAwB,4CAAG,yGACTC,SADS,gBAEbC,WAAUC,MAAV,CAAiB,wCAAjB,CAA2D,EAA3D,CAFa,0BAEzBC,IAFyB,4BACIC,MADJ,wBACvBC,CADuB,QAI7BA,CAAK,CAACC,IAAN,GAJ6B,yBAKtBD,CALsB,2CAAH,uD,CAkBjBE,CAAO,4CAAG,WAAMC,CAAN,CAAiBC,CAAjB,CAA8BC,CAA9B,CAA2CC,CAA3C,CAAwDC,CAAxD,oHA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ACP,CACJ,CACJ,CAPD,IAOO,CACHO,CAAM,CAACI,MAAP,CAAgB,UAAW,CACvBX,CAAI,EACP,CACJ,CAEDO,CAAM,CAACK,YAAP,CAAoB,KAApB,CAA2Bb,CAA3B,EACAI,QAAQ,CAACU,IAAT,CAAcC,WAAd,CAA0BP,CAA1B,EAEA3C,CAAoB,CAACqC,eAArB,CAAuCF,CAC1C,CApCD,CA4CAnC,CAAoB,CAACqC,eAArB,CAAuC,E","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This module is responsible for PayPal content in the gateways modal.\n *\n * @module paygw_paypal/gateway_modal\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport * as Repository from './repository';\nimport Templates from 'core/templates';\nimport Truncate from 'core/truncate';\nimport Ajax from 'core/ajax';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\nimport {get_string as getString} from 'core/str';\n\n/**\n * Creates and shows a modal that contains a placeholder.\n *\n * @returns {Promise}\n */\nconst showModalWithPlaceholder = async() => {\n const modal = await ModalFactory.create({\n body: await Templates.render('paygw_paypal/paypal_button_placeholder', {})\n });\n modal.show();\n return modal;\n};\n\n/**\n * Process the payment.\n *\n * @param {string} component Name of the component that the componentId belongs to\n * @param {string} paymentArea The area of the component that the componentId belongs to\n * @param {number} componentId An internal identifier that is used by the component\n * @param {string} description Description of the payment\n * @param {processCallback} callback The callback function to call when processing is finished\n * @returns {Promise}\n */\nexport const process = async(component, paymentArea, componentId, description, callback) => {\n\n const [\n modal,\n paypalConfig,\n ] = await Promise.all([\n showModalWithPlaceholder(),\n Repository.getConfigForJs(component, paymentArea, componentId),\n ]);\n const currency = paypalConfig.currency;\n const amount = paypalConfig.cost; // Cost with surcharge.\n\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Destroy when hidden.\n modal.destroy();\n });\n\n const paypalScript = `https://www.paypal.com/sdk/js?client-id=${paypalConfig.clientid}¤cy=${currency}`;\n\n callExternalFunction(paypalScript, () => {\n modal.setBody(''); // We have to clear the body. The render method in paypal.Buttons will render everything.\n\n paypal.Buttons({ // eslint-disable-line\n // Set up the transaction.\n createOrder: function(data, actions) {\n return actions.order.create({\n purchase_units: [{ // eslint-disable-line\n amount: {\n currency_code: currency, // eslint-disable-line\n value: amount\n },\n description: Truncate.truncate(description, {length: 127, stripTags: true}),\n }],\n application_context: { // eslint-disable-line\n shipping_preference: 'NO_SHIPPING', // eslint-disable-line\n brand_name: Truncate.truncate(paypalConfig.brandname, {length: 127, stripTags: true}), // eslint-disable-line\n },\n });\n },\n // Finalise the transaction.\n onApprove: function(data) {\n modal.getRoot().on(ModalEvents.outsideClick, (e) => {\n // Prevent closing the modal when clicking outside of it.\n e.preventDefault();\n });\n\n modal.setBody(getString('authorising', 'paygw_paypal'));\n\n // Call server to validate and capture payment for order.\n return Ajax.call([{\n methodname: 'paygw_paypal_create_transaction_complete',\n args: {\n component,\n paymentarea: paymentArea,\n componentid: componentId,\n orderid: data.orderID,\n },\n }])[0]\n .then(function(res) {\n modal.hide();\n return callback(res);\n });\n }\n }).render(modal.getBody()[0]);\n });\n};\n\n/**\n * The callback definition for process.\n *\n * @callback processCallback\n * @param {bool} success\n * @param {string} message\n */\n\n/**\n * Calls a function from an external javascript file.\n *\n * @param {string} jsFile URL of the external JavaScript file\n * @param {function} func The function to call\n */\nconst callExternalFunction = (jsFile, func) => {\n // Check to see if this file has already been loaded. If so just go straight to the func.\n if (callExternalFunction.currentlyloaded == jsFile) {\n func();\n return;\n }\n\n // PayPal can only work with one currency at the same time. We have to unload the previously loaded script\n // if it was loaded for a different currency. Weird way indeed, but the only way.\n // See: https://github.com/paypal/paypal-checkout-components/issues/1180\n if (callExternalFunction.currentlyloaded) {\n const suspectedScript = document.querySelector(`script[src=\"${callExternalFunction.currentlyloaded}\"]`);\n if (suspectedScript) {\n suspectedScript.parentNode.removeChild(suspectedScript);\n }\n }\n\n const script = document.createElement('script');\n\n if (script.readyState) {\n script.onreadystatechange = function() {\n if (this.readyState == 'complete' || this.readyState == 'loaded') {\n this.onreadystatechange = null;\n func();\n }\n };\n } else {\n script.onload = function() {\n func();\n };\n }\n\n script.setAttribute('src', jsFile);\n document.head.appendChild(script);\n\n callExternalFunction.currentlyloaded = jsFile;\n};\n\n/**\n * Holds the full url of loaded external JavaScript file.\n *\n * @static\n * @type {string}\n */\ncallExternalFunction.currentlyloaded = '';\n"],"file":"gateways_modal.min.js"} \ No newline at end of file diff --git a/payment/gateway/paypal/amd/build/repository.min.js b/payment/gateway/paypal/amd/build/repository.min.js index d0cc2e92ce6..af79a9eafb1 100644 --- a/payment/gateway/paypal/amd/build/repository.min.js +++ b/payment/gateway/paypal/amd/build/repository.min.js @@ -1,2 +1,2 @@ -define ("pg_paypal/repository",["exports","core/ajax"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.getConfigForJs=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var c=function(a,c,d){return b.default.call([{methodname:"pg_paypal_get_config_for_js",args:{component:a,paymentarea:c,componentid:d}}])[0]};a.getConfigForJs=c}); +define ("paygw_paypal/repository",["exports","core/ajax"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.getConfigForJs=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var c=function(a,c,d){return b.default.call([{methodname:"paygw_paypal_get_config_for_js",args:{component:a,paymentarea:c,componentid:d}}])[0]};a.getConfigForJs=c}); //# sourceMappingURL=repository.min.js.map diff --git a/payment/gateway/paypal/amd/build/repository.min.js.map b/payment/gateway/paypal/amd/build/repository.min.js.map index 0c7f8d17741..af94441f381 100644 --- a/payment/gateway/paypal/amd/build/repository.min.js.map +++ b/payment/gateway/paypal/amd/build/repository.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/repository.js"],"names":["getConfigForJs","component","paymentArea","componentId","Ajax","call","methodname","args","paymentarea","componentid"],"mappings":"2JAwBA,uDAUO,GAAMA,CAAAA,CAAc,CAAG,SAACC,CAAD,CAAYC,CAAZ,CAAyBC,CAAzB,CAAyC,CAUnE,MAAOC,WAAKC,IAAL,CAAU,CATD,CACZC,UAAU,CAAE,6BADA,CAEZC,IAAI,CAAE,CACFN,SAAS,CAATA,CADE,CAEFO,WAAW,CAAEN,CAFX,CAGFO,WAAW,CAAEN,CAHX,CAFM,CASC,CAAV,EAAqB,CAArB,CACV,CAXM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * PayPal repository module to encapsulate all of the AJAX requests that can be sent for PayPal.\n *\n * @module pg_paypal/repository\n * @package pg_paypal\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\n\n/**\n * Return the PayPal JavaScript SDK URL.\n *\n * @param {string} component Name of the component that the componentid belongs to\n * @param {string} paymentArea The area of the component that the componentid belongs to\n * @param {number} componentId An internal identifier that is used by the component\n * @returns {Promise<{clientid: string, brandname: string}>}\n */\nexport const getConfigForJs = (component, paymentArea, componentId) => {\n const request = {\n methodname: 'pg_paypal_get_config_for_js',\n args: {\n component,\n paymentarea: paymentArea,\n componentid: componentId,\n },\n };\n\n return Ajax.call([request])[0];\n};\n"],"file":"repository.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/repository.js"],"names":["getConfigForJs","component","paymentArea","componentId","Ajax","call","methodname","args","paymentarea","componentid"],"mappings":"8JAwBA,uDAUO,GAAMA,CAAAA,CAAc,CAAG,SAACC,CAAD,CAAYC,CAAZ,CAAyBC,CAAzB,CAAyC,CAUnE,MAAOC,WAAKC,IAAL,CAAU,CATD,CACZC,UAAU,CAAE,gCADA,CAEZC,IAAI,CAAE,CACFN,SAAS,CAATA,CADE,CAEFO,WAAW,CAAEN,CAFX,CAGFO,WAAW,CAAEN,CAHX,CAFM,CASC,CAAV,EAAqB,CAArB,CACV,CAXM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * PayPal repository module to encapsulate all of the AJAX requests that can be sent for PayPal.\n *\n * @module paygw_paypal/repository\n * @package paygw_paypal\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\n\n/**\n * Return the PayPal JavaScript SDK URL.\n *\n * @param {string} component Name of the component that the componentid belongs to\n * @param {string} paymentArea The area of the component that the componentid belongs to\n * @param {number} componentId An internal identifier that is used by the component\n * @returns {Promise<{clientid: string, brandname: string}>}\n */\nexport const getConfigForJs = (component, paymentArea, componentId) => {\n const request = {\n methodname: 'paygw_paypal_get_config_for_js',\n args: {\n component,\n paymentarea: paymentArea,\n componentid: componentId,\n },\n };\n\n return Ajax.call([request])[0];\n};\n"],"file":"repository.min.js"} \ No newline at end of file diff --git a/payment/gateway/paypal/amd/src/gateways_modal.js b/payment/gateway/paypal/amd/src/gateways_modal.js index 9858b637579..59f4bb1e231 100644 --- a/payment/gateway/paypal/amd/src/gateways_modal.js +++ b/payment/gateway/paypal/amd/src/gateways_modal.js @@ -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 * @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, diff --git a/payment/gateway/paypal/amd/src/repository.js b/payment/gateway/paypal/amd/src/repository.js index 50cfc413670..627c95d419a 100644 --- a/payment/gateway/paypal/amd/src/repository.js +++ b/payment/gateway/paypal/amd/src/repository.js @@ -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 * @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, diff --git a/payment/gateway/paypal/classes/external/get_config_for_js.php b/payment/gateway/paypal/classes/external/get_config_for_js.php index bf6ccc69f80..0cd110f9977 100644 --- a/payment/gateway/paypal/classes/external/get_config_for_js.php +++ b/payment/gateway/paypal/classes/external/get_config_for_js.php @@ -17,14 +17,14 @@ /** * This class contains a list of webservice functions related to the PayPal payment gateway. * - * @package pg_paypal + * @package paygw_paypal * @copyright 2020 Shamim Rezaie * @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; diff --git a/payment/gateway/paypal/classes/external/transaction_complete.php b/payment/gateway/paypal/classes/external/transaction_complete.php index 2a895283cc8..251272d290b 100644 --- a/payment/gateway/paypal/classes/external/transaction_complete.php +++ b/payment/gateway/paypal/classes/external/transaction_complete.php @@ -17,21 +17,21 @@ /** * This class contains a list of webservice functions related to the PayPal payment gateway. * - * @package pg_paypal + * @package paygw_paypal * @copyright 2020 Shamim Rezaie * @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 [ diff --git a/payment/gateway/paypal/classes/gateway.php b/payment/gateway/paypal/classes/gateway.php index 438cef6d763..42519dbb679 100644 --- a/payment/gateway/paypal/classes/gateway.php +++ b/payment/gateway/paypal/classes/gateway.php @@ -17,12 +17,12 @@ /** * Contains class for PayPal payment gateway. * - * @package pg_paypal + * @package paygw_paypal * @copyright 2019 Shamim Rezaie * @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'); } /** diff --git a/payment/gateway/paypal/classes/paypal_helper.php b/payment/gateway/paypal/classes/paypal_helper.php index ff3409a3409..a2395f4d066 100644 --- a/payment/gateway/paypal/classes/paypal_helper.php +++ b/payment/gateway/paypal/classes/paypal_helper.php @@ -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; diff --git a/payment/gateway/paypal/db/install.php b/payment/gateway/paypal/db/install.php index a6be0d75ce0..f9ca2d6eb8f 100644 --- a/payment/gateway/paypal/db/install.php +++ b/payment/gateway/paypal/db/install.php @@ -15,15 +15,15 @@ // along with Moodle. If not, see . /** - * 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']))); } diff --git a/payment/gateway/paypal/db/install.xml b/payment/gateway/paypal/db/install.xml index 808f99e8399..cd145cec969 100755 --- a/payment/gateway/paypal/db/install.xml +++ b/payment/gateway/paypal/db/install.xml @@ -4,7 +4,7 @@ xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd" > - +
diff --git a/payment/gateway/paypal/db/services.php b/payment/gateway/paypal/db/services.php index 9e6d9a74bd8..f1986c6ba44 100644 --- a/payment/gateway/paypal/db/services.php +++ b/payment/gateway/paypal/db/services.php @@ -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 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -25,16 +25,16 @@ 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.', diff --git a/payment/gateway/paypal/lang/en/pg_paypal.php b/payment/gateway/paypal/lang/en/paygw_paypal.php similarity index 96% rename from payment/gateway/paypal/lang/en/pg_paypal.php rename to payment/gateway/paypal/lang/en/paygw_paypal.php index 3a176b05a4d..f3c34cab1a4 100644 --- a/payment/gateway/paypal/lang/en/pg_paypal.php +++ b/payment/gateway/paypal/lang/en/paygw_paypal.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see . /** - * Strings for component 'pg_paypal', language 'en' + * Strings for component 'paygw_paypal', language 'en' * - * @package pg_paypal + * @package paygw_paypal * @copyright 2019 Shamim Rezaie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/payment/gateway/paypal/settings.php b/payment/gateway/paypal/settings.php index 92ddb89d7f5..adbe251b27c 100644 --- a/payment/gateway/paypal/settings.php +++ b/payment/gateway/paypal/settings.php @@ -17,7 +17,7 @@ /** * Settings for the PayPal payment gateway * - * @package pg_paypal + * @package paygw_paypal * @copyright 2019 Shamim Rezaie * @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'); } diff --git a/payment/gateway/paypal/version.php b/payment/gateway/paypal/version.php index 2ff3fadd826..e0e23ba9863 100644 --- a/payment/gateway/paypal/version.php +++ b/payment/gateway/paypal/version.php @@ -17,7 +17,7 @@ /** * Version information * - * @package pg_paypal + * @package paygw_paypal * @copyright 2019 Shamim Rezaie * @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). diff --git a/payment/manage_account.php b/payment/manage_account.php index 2d92e6cead2..d5d2e263f12 100644 --- a/payment/manage_account.php +++ b/payment/manage_account.php @@ -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()); diff --git a/payment/manage_gateway.php b/payment/manage_gateway.php index 2833d2cb4d2..2a6c21d162b 100644 --- a/payment/manage_gateway.php +++ b/payment/manage_gateway.php @@ -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); diff --git a/payment/templates/gateway.mustache b/payment/templates/gateway.mustache index bc0369496e0..4189f9ffef0 100644 --- a/payment/templates/gateway.mustache +++ b/payment/templates/gateway.mustache @@ -46,6 +46,6 @@ \ No newline at end of file diff --git a/payment/tests/generator/lib.php b/payment/tests/generator/lib.php index 2ccf5b41f9b..48f46490b40 100644 --- a/payment/tests/generator/lib.php +++ b/payment/tests/generator/lib.php @@ -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); } diff --git a/payment/tests/helper_test.php b/payment/tests/helper_test.php index 98ef3dda1e6..41776503314 100644 --- a/payment/tests/helper_test.php +++ b/payment/tests/helper_test.php @@ -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;