From e1cab8e18e29604bbedc4074cf450203d037d912 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 16 Dec 2019 23:14:51 +1100 Subject: [PATCH] MDL-69166 pg_paypal: A new payment gateway is born --- lib/classes/plugin_manager.php | 1 + payment/gateway/paypal/classes/gateway.php | 44 ++++++++++++++++++++ payment/gateway/paypal/lang/en/pg_paypal.php | 28 +++++++++++++ payment/gateway/paypal/settings.php | 30 +++++++++++++ payment/gateway/paypal/version.php | 29 +++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 payment/gateway/paypal/classes/gateway.php create mode 100644 payment/gateway/paypal/lang/en/pg_paypal.php create mode 100644 payment/gateway/paypal/settings.php create mode 100644 payment/gateway/paypal/version.php diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 1417eeffdeb..6625b95d52f 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1924,6 +1924,7 @@ class core_plugin_manager { ), 'pg' => [ + 'paypal', ], 'plagiarism' => array( diff --git a/payment/gateway/paypal/classes/gateway.php b/payment/gateway/paypal/classes/gateway.php new file mode 100644 index 00000000000..864406aaf2e --- /dev/null +++ b/payment/gateway/paypal/classes/gateway.php @@ -0,0 +1,44 @@ +. + +/** + * Contains class for PayPal payment gateway. + * + * @package pg_paypal + * @copyright 2019 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace pg_paypal; + +defined('MOODLE_INTERNAL') || die(); + +/** + * The gateway class for PayPal payment gateway. + * + * @copyright 2019 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class gateway extends \core_payment\gateway { + public static function get_supported_currencies(): array { + // See https://developer.paypal.com/docs/api/reference/currency-codes/, + // 3-character ISO-4217: https://en.wikipedia.org/wiki/ISO_4217#Active_codes. + return [ + 'AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'INR', 'JPY', + 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'USD' + ]; + } +} diff --git a/payment/gateway/paypal/lang/en/pg_paypal.php b/payment/gateway/paypal/lang/en/pg_paypal.php new file mode 100644 index 00000000000..f64015e823b --- /dev/null +++ b/payment/gateway/paypal/lang/en/pg_paypal.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for component 'pg_paypal', language 'en' + * + * @package pg_paypal + * @copyright 2019 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['gatewaydescription'] = 'PayPal is an authorised payment gateway provider for processing credit card transactions.'; +$string['gatewayname'] = 'PayPal'; +$string['pluginname'] = 'PayPal'; +$string['pluginname_desc'] = 'The PayPal plugin allows you to receive payments via PayPal.'; diff --git a/payment/gateway/paypal/settings.php b/payment/gateway/paypal/settings.php new file mode 100644 index 00000000000..0c07be168af --- /dev/null +++ b/payment/gateway/paypal/settings.php @@ -0,0 +1,30 @@ +. + +/** + * Settings for the PayPal payment gateway + * + * @package pg_paypal + * @copyright 2019 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +if ($ADMIN->fulltree) { + $settings->add(new admin_setting_heading('pg_paypal_settings', '', get_string('pluginname_desc', 'pg_paypal'))); + +} diff --git a/payment/gateway/paypal/version.php b/payment/gateway/paypal/version.php new file mode 100644 index 00000000000..c43d1a9fcc8 --- /dev/null +++ b/payment/gateway/paypal/version.php @@ -0,0 +1,29 @@ +. + +/** + * Version information + * + * @package pg_paypal + * @copyright 2019 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2020102700; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2020060900; // Requires this Moodle version. +$plugin->component = 'pg_paypal'; // Full name of the plugin (used for diagnostics).