MDL-69166 core_payment: Renamed plugintype name from pg to paygw
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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';
|
||||
|
||||
@@ -1923,7 +1923,7 @@ class core_plugin_manager {
|
||||
'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop'
|
||||
),
|
||||
|
||||
'pg' => [
|
||||
'paygw' => [
|
||||
'paypal',
|
||||
],
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
"theme": "theme",
|
||||
"local": "local",
|
||||
"h5plib": "h5p\/h5plib",
|
||||
"pg": "payment\/gateway"
|
||||
"paygw": "payment\/gateway"
|
||||
},
|
||||
"subsystems": {
|
||||
"access": null,
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
+1
-1
@@ -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<z.length&&z[1]!==void 0?z[1]:{},n=m.focusOnClose,o=void 0===n?null:n;a.t0=b.default;a.t1=k.default.TYPE;a.next=5;return(0,d.get_string)("selectpaymenttype","core_payment");case 5:a.t2=a.sent;a.next=8;return c.default.render("core_payment/gateways_modal",{});case 8:a.t3=a.sent;a.t4={type:a.t1,title:a.t2,body:a.t3};a.next=12;return a.t0.create.call(a.t0,a.t4);case 12:p=a.sent;q=p.getRoot()[0];(0,i.addToastRegion)(q);p.show();p.getRoot().on(g.default.hidden,function(){p.destroy();try{o.focus()}catch(a){}});p.getRoot().on(h.default.proceed,function(a){var b=(q.querySelector(f.default.values.gateway)||{value:""}).value;if(b){t(b,l.dataset.component,l.dataset.paymentarea,l.dataset.componentid,l.dataset.description,function(a){var b=a.success,c=a.message,d=void 0===c?"":c;p.hide();if(b){j.default.addNotification({message:d,type:"success"});location.reload()}else{j.default.alert("",d)}})}else{(0,d.get_string)("nogatewayselected","core_payment").then(function(a){return(0,i.add)(a)})}a.preventDefault()});q.addEventListener("change",function(a){if(a.target.matches(f.default.elements.gateways)){s(q,l.dataset.cost)}});a.next=21;return(0,e.getAvailableGateways)(l.dataset.component,l.dataset.paymentarea,l.dataset.componentid);case 21:u=a.sent;v={gateways:u};a.next=25;return c.default.renderForPromise("core_payment/gateways",v);case 25:w=a.sent;x=w.html;y=w.js;c.default.replaceNodeContents(q.querySelector(f.default.regions.gatewaysContainer),x,y);r(q);a.next=32;return s(q,l.dataset.cost);case 32:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),r=function(a){var b=a.querySelectorAll(f.default.elements.gateways);if(1==b.length){b[0].checked=!0}},s=function(){var a=n(regeneratorRuntime.mark(function a(b){var d,e,g,h,i,j,k,l=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=1<l.length&&l[1]!==void 0?l[1]:"";e=b.querySelector(f.default.values.gateway);g=parseInt((e||{dataset:{surcharge:0}}).dataset.surcharge);h=(e||{dataset:{cost:d}}).dataset.cost;a.next=6;return c.default.renderForPromise("core_payment/fee_breakdown",{fee:h,surcharge:g});case 6:i=a.sent;j=i.html;k=i.js;c.default.replaceNodeContents(b.querySelector(f.default.regions.costContainer),j,k);case 10:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),t=function(){var a=n(regeneratorRuntime.mark(function a(b,c,d,e,f,g){var h;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return"function"==typeof o.define&&o.define.amd?new Promise(function(a,c){o.require(["pg_".concat(b,"/gateways_modal")],a,c)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&o.require&&"component"===o.require.loader?Promise.resolve(require(("pg_".concat(b,"/gateways_modal")))):Promise.resolve(o["pg_".concat(b,"/gateways_modal")]);case 2:h=a.sent;h.process(c,d,e,f,g);case 4:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}()});
|
||||
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<z.length&&z[1]!==void 0?z[1]:{},n=m.focusOnClose,o=void 0===n?null:n;a.t0=b.default;a.t1=k.default.TYPE;a.next=5;return(0,d.get_string)("selectpaymenttype","core_payment");case 5:a.t2=a.sent;a.next=8;return c.default.render("core_payment/gateways_modal",{});case 8:a.t3=a.sent;a.t4={type:a.t1,title:a.t2,body:a.t3};a.next=12;return a.t0.create.call(a.t0,a.t4);case 12:p=a.sent;q=p.getRoot()[0];(0,i.addToastRegion)(q);p.show();p.getRoot().on(g.default.hidden,function(){p.destroy();try{o.focus()}catch(a){}});p.getRoot().on(h.default.proceed,function(a){var b=(q.querySelector(f.default.values.gateway)||{value:""}).value;if(b){t(b,l.dataset.component,l.dataset.paymentarea,l.dataset.componentid,l.dataset.description,function(a){var b=a.success,c=a.message,d=void 0===c?"":c;p.hide();if(b){j.default.addNotification({message:d,type:"success"});location.reload()}else{j.default.alert("",d)}})}else{(0,d.get_string)("nogatewayselected","core_payment").then(function(a){return(0,i.add)(a)})}a.preventDefault()});q.addEventListener("change",function(a){if(a.target.matches(f.default.elements.gateways)){s(q,l.dataset.cost)}});a.next=21;return(0,e.getAvailableGateways)(l.dataset.component,l.dataset.paymentarea,l.dataset.componentid);case 21:u=a.sent;v={gateways:u};a.next=25;return c.default.renderForPromise("core_payment/gateways",v);case 25:w=a.sent;x=w.html;y=w.js;c.default.replaceNodeContents(q.querySelector(f.default.regions.gatewaysContainer),x,y);r(q);a.next=32;return s(q,l.dataset.cost);case 32:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),r=function(a){var b=a.querySelectorAll(f.default.elements.gateways);if(1==b.length){b[0].checked=!0}},s=function(){var a=n(regeneratorRuntime.mark(function a(b){var d,e,g,h,i,j,k,l=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=1<l.length&&l[1]!==void 0?l[1]:"";e=b.querySelector(f.default.values.gateway);g=parseInt((e||{dataset:{surcharge:0}}).dataset.surcharge);h=(e||{dataset:{cost:d}}).dataset.cost;a.next=6;return c.default.renderForPromise("core_payment/fee_breakdown",{fee:h,surcharge:g});case 6:i=a.sent;j=i.html;k=i.js;c.default.replaceNodeContents(b.querySelector(f.default.regions.costContainer),j,k);case 10:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),t=function(){var a=n(regeneratorRuntime.mark(function a(b,c,d,e,f,g){var h;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return"function"==typeof o.define&&o.define.amd?new Promise(function(a,c){o.require(["paygw_".concat(b,"/gateways_modal")],a,c)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&o.require&&"component"===o.require.loader?Promise.resolve(require(("paygw_".concat(b,"/gateways_modal")))):Promise.resolve(o["paygw_".concat(b,"/gateways_modal")]);case 2:h=a.sent;h.process(c,d,e,f,g);case 4:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}()});
|
||||
//# sourceMappingURL=gateways_modal.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -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),
|
||||
];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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'),
|
||||
|
||||
+1
-1
@@ -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);c<b;c++){d[c]=a[c]}return d}function q(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function r(a){if(Array.isArray(a))return a}function s(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 t(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){s(h,d,e,f,g,"next",a)}function g(a){s(h,d,e,f,g,"throw",a)}f(void 0)})}}var u=function(){var a=t(regeneratorRuntime.mark(function a(){var b;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.t0=f.default;a.next=3;return c.default.render("pg_paypal/paypal_button_placeholder",{});case 3:a.t1=a.sent;a.t2={body:a.t1};a.next=7;return a.t0.create.call(a.t0,a.t2);case 7:b=a.sent;b.show();return a.abrupt("return",b);case 10:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),v=function(){var a=t(regeneratorRuntime.mark(function a(c,f,i,j,k){var m,n,o,p,q,r,s;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return Promise.all([u(),b.getConfigForJs(c,f,i)]);case 2:m=a.sent;n=l(m,2);o=n[0];p=n[1];q=p.currency;r=p.cost;o.getRoot().on(g.default.hidden,function(){o.destroy()});s="https://www.paypal.com/sdk/js?client-id=".concat(p.clientid,"¤cy=").concat(q);w(s,function(){o.setBody("");paypal.Buttons({createOrder:function createOrder(a,b){return b.order.create({purchase_units:[{amount:{currency_code:q,value:r},description:d.default.truncate(j,{length:127,stripTags:!0})}],application_context:{shipping_preference:"NO_SHIPPING",brand_name:d.default.truncate(p.brandname,{length:127,stripTags:!0})}})},onApprove:function onApprove(a){o.getRoot().on(g.default.outsideClick,function(a){a.preventDefault()});o.setBody((0,h.get_string)("authorising","pg_paypal"));return e.default.call([{methodname:"pg_paypal_create_transaction_complete",args:{component:c,paymentarea:f,componentid:i,orderid:a.orderID}}])[0].then(function(a){o.hide();return k(a)})}}).render(o.getBody()[0])});case 11:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.process=v;var w=function(a,b){if(w.currentlyloaded==a){b();return}if(w.currentlyloaded){var d=document.querySelector("script[src=\"".concat(w.currentlyloaded,"\"]"));if(d){d.parentNode.removeChild(d)}}var c=document.createElement("script");if(c.readyState){c.onreadystatechange=function(){if("complete"==this.readyState||"loaded"==this.readyState){this.onreadystatechange=null;b()}}}else{c.onload=function(){b()}}c.setAttribute("src",a);document.head.appendChild(c);w.currentlyloaded=a};w.currentlyloaded=""});
|
||||
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 ("paygw_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);c<b;c++){d[c]=a[c]}return d}function q(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function r(a){if(Array.isArray(a))return a}function s(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 t(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){s(h,d,e,f,g,"next",a)}function g(a){s(h,d,e,f,g,"throw",a)}f(void 0)})}}var u=function(){var a=t(regeneratorRuntime.mark(function a(){var b;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.t0=f.default;a.next=3;return c.default.render("paygw_paypal/paypal_button_placeholder",{});case 3:a.t1=a.sent;a.t2={body:a.t1};a.next=7;return a.t0.create.call(a.t0,a.t2);case 7:b=a.sent;b.show();return a.abrupt("return",b);case 10:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),v=function(){var a=t(regeneratorRuntime.mark(function a(c,f,i,j,k){var m,n,o,p,q,r,s;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return Promise.all([u(),b.getConfigForJs(c,f,i)]);case 2:m=a.sent;n=l(m,2);o=n[0];p=n[1];q=p.currency;r=p.cost;o.getRoot().on(g.default.hidden,function(){o.destroy()});s="https://www.paypal.com/sdk/js?client-id=".concat(p.clientid,"¤cy=").concat(q);w(s,function(){o.setBody("");paypal.Buttons({createOrder:function createOrder(a,b){return b.order.create({purchase_units:[{amount:{currency_code:q,value:r},description:d.default.truncate(j,{length:127,stripTags:!0})}],application_context:{shipping_preference:"NO_SHIPPING",brand_name:d.default.truncate(p.brandname,{length:127,stripTags:!0})}})},onApprove:function onApprove(a){o.getRoot().on(g.default.outsideClick,function(a){a.preventDefault()});o.setBody((0,h.get_string)("authorising","paygw_paypal"));return e.default.call([{methodname:"paygw_paypal_create_transaction_complete",args:{component:c,paymentarea:f,componentid:i,orderid:a.orderID}}])[0].then(function(a){o.hide();return k(a)})}}).render(o.getBody()[0])});case 11:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.process=v;var w=function(a,b){if(w.currentlyloaded==a){b();return}if(w.currentlyloaded){var d=document.querySelector("script[src=\"".concat(w.currentlyloaded,"\"]"));if(d){d.parentNode.removeChild(d)}}var c=document.createElement("script");if(c.readyState){c.onreadystatechange=function(){if("complete"==this.readyState||"loaded"==this.readyState){this.onreadystatechange=null;b()}}}else{c.onload=function(){b()}}c.setAttribute("src",a);document.head.appendChild(c);w.currentlyloaded=a};w.currentlyloaded=""});
|
||||
//# sourceMappingURL=gateways_modal.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -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
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.\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 <[email protected]>\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"}
|
||||
{"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 <http://www.gnu.org/licenses/>.\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 <[email protected]>\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"}
|
||||
@@ -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 <[email protected]>
|
||||
* @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,
|
||||
|
||||
@@ -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 <[email protected]>
|
||||
* @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,
|
||||
|
||||
@@ -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 <[email protected]>
|
||||
* @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;
|
||||
|
||||
@@ -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 <[email protected]>
|
||||
* @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 [
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
/**
|
||||
* Contains class for PayPal payment gateway.
|
||||
*
|
||||
* @package pg_paypal
|
||||
* @package paygw_paypal
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
// 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'])));
|
||||
}
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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 <[email protected]>
|
||||
* @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.',
|
||||
|
||||
+2
-2
@@ -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
|
||||
*/
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Settings for the PayPal payment gateway
|
||||
*
|
||||
* @package pg_paypal
|
||||
* @package paygw_paypal
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @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');
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Version information
|
||||
*
|
||||
* @package pg_paypal
|
||||
* @package paygw_paypal
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @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).
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user