mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-69166 pg_paypal: WS and AMD to return some settings to be used in js
This commit is contained in:
parent
8ef156b7dc
commit
e75112a886
2
payment/gateway/paypal/amd/build/repository.min.js
vendored
Normal file
2
payment/gateway/paypal/amd/build/repository.min.js
vendored
Normal file
@ -0,0 +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(){return b.default.call([{methodname:"pg_paypal_get_config_for_js",args:{}}])[0]};a.getConfigForJs=c});
|
||||
//# sourceMappingURL=repository.min.js.map
|
1
payment/gateway/paypal/amd/build/repository.min.js.map
Normal file
1
payment/gateway/paypal/amd/build/repository.min.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/repository.js"],"names":["getConfigForJs","Ajax","call","methodname","args"],"mappings":"2JAwBA,uDAOO,GAAMA,CAAAA,CAAc,CAAG,UAAM,CAMhC,MAAOC,WAAKC,IAAL,CAAU,CALD,CACZC,UAAU,CAAE,6BADA,CAEZC,IAAI,CAAE,EAFM,CAKC,CAAV,EAAqB,CAArB,CACV,CAPM,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 <shamim@moodle.com>\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 * @returns {Promise<{clientid: String, brandname: String}>}\n */\nexport const getConfigForJs = () => {\n const request = {\n methodname: 'pg_paypal_get_config_for_js',\n args: {},\n };\n\n return Ajax.call([request])[0];\n};\n"],"file":"repository.min.js"}
|
39
payment/gateway/paypal/amd/src/repository.js
Normal file
39
payment/gateway/paypal/amd/src/repository.js
Normal file
@ -0,0 +1,39 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* PayPal repository module to encapsulate all of the AJAX requests that can be sent for PayPal.
|
||||
*
|
||||
* @module pg_paypal/repository
|
||||
* @package pg_paypal
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import Ajax from 'core/ajax';
|
||||
|
||||
/**
|
||||
* Return the PayPal JavaScript SDK URL.
|
||||
*
|
||||
* @returns {Promise<{clientid: String, brandname: String}>}
|
||||
*/
|
||||
export const getConfigForJs = () => {
|
||||
const request = {
|
||||
methodname: 'pg_paypal_get_config_for_js',
|
||||
args: {},
|
||||
};
|
||||
|
||||
return Ajax.call([request])[0];
|
||||
};
|
74
payment/gateway/paypal/classes/external/get_config_for_js.php
vendored
Normal file
74
payment/gateway/paypal/classes/external/get_config_for_js.php
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This class contains a list of webservice functions related to the PayPal payment gateway.
|
||||
*
|
||||
* @package pg_paypal
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pg_paypal\external;
|
||||
|
||||
use external_api;
|
||||
use external_function_parameters;
|
||||
use external_value;
|
||||
use external_single_structure;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/externallib.php');
|
||||
|
||||
class get_config_for_js extends external_api {
|
||||
|
||||
/**
|
||||
* Returns description of method parameters.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
*/
|
||||
public static function execute_parameters(): external_function_parameters {
|
||||
return new external_function_parameters([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full URL of the PayPal JavaScript SDK.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function execute(): array {
|
||||
$config = get_config('pg_paypal');
|
||||
|
||||
return [
|
||||
'clientid' => $config->clientid,
|
||||
'brandname' => $config->brandname,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value.
|
||||
*
|
||||
* @return external_single_structure
|
||||
*/
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'clientid' => new external_value(PARAM_TEXT, 'PayPal client ID'),
|
||||
'brandname' => new external_value(PARAM_TEXT, 'Brand name'),
|
||||
]);
|
||||
}
|
||||
}
|
36
payment/gateway/paypal/db/services.php
Normal file
36
payment/gateway/paypal/db/services.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External functions and service definitions for the PayPal payment gateway plugin.
|
||||
*
|
||||
* @package pg_paypal
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$functions = [
|
||||
'pg_paypal_get_config_for_js' => [
|
||||
'classname' => 'pg_paypal\external\get_config_for_js',
|
||||
'methodname' => 'execute',
|
||||
'classpath' => '',
|
||||
'description' => 'Returns the configuration settings to be used in js',
|
||||
'type' => 'read',
|
||||
'ajax' => true,
|
||||
],
|
||||
];
|
@ -22,6 +22,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['brandname'] = 'Brand name';
|
||||
$string['brandname_desc'] = 'The optional label that overrides the business name in the PayPal account on the PayPal site.';
|
||||
$string['clientid'] = 'Client ID';
|
||||
$string['clientid_desc'] = 'The client ID that PayPal generated for your application.';
|
||||
$string['gatewaydescription'] = 'PayPal is an authorised payment gateway provider for processing credit card transactions.';
|
||||
$string['gatewayname'] = 'PayPal';
|
||||
$string['pluginname'] = 'PayPal';
|
||||
|
@ -27,4 +27,8 @@ 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_configtext('pg_paypal/brandname', get_string('brandname', 'pg_paypal'),
|
||||
get_string('brandname', 'pg_paypal'), '', PARAM_TEXT));
|
||||
$settings->add(new admin_setting_configtext('pg_paypal/clientid', get_string('clientid', 'pg_paypal'),
|
||||
get_string('clientid_desc', 'pg_paypal'), '', PARAM_TEXT));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user