From e9de4309071865bd7e7c2355097bdf8157bc02b6 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Wed, 29 Jan 2020 19:11:37 +1100 Subject: [PATCH] MDL-69166 core_payment: display the gateways modal --- enrol/fee/classes/plugin.php | 9 +- lang/en/payment.php | 2 + payment/amd/build/gateways_modal.min.js | Bin 0 -> 3183 bytes payment/amd/build/gateways_modal.min.js.map | Bin 0 -> 5275 bytes payment/amd/build/repository.min.js | Bin 0 -> 427 bytes payment/amd/build/repository.min.js.map | Bin 0 -> 1867 bytes payment/amd/build/selectors.min.js | Bin 0 -> 277 bytes payment/amd/build/selectors.min.js.map | Bin 0 -> 1302 bytes payment/amd/src/gateways_modal.js | 94 ++++++++++++++++++ payment/amd/src/repository.js | 41 ++++++++ payment/amd/src/selectors.js | 29 ++++++ payment/classes/helper.php | 31 ++++++ payment/templates/gateway.mustache | 48 +++++++++ payment/templates/gateways.mustache | 55 ++++++++++ payment/templates/gateways_modal.mustache | 37 +++++++ .../templates/gateways_placeholder.mustache | 41 ++++++++ 16 files changed, 384 insertions(+), 3 deletions(-) create mode 100644 payment/amd/build/gateways_modal.min.js create mode 100644 payment/amd/build/gateways_modal.min.js.map create mode 100644 payment/amd/build/repository.min.js create mode 100644 payment/amd/build/repository.min.js.map create mode 100644 payment/amd/build/selectors.min.js create mode 100644 payment/amd/build/selectors.min.js.map create mode 100644 payment/amd/src/gateways_modal.js create mode 100644 payment/amd/src/repository.js create mode 100644 payment/amd/src/selectors.js create mode 100644 payment/templates/gateway.mustache create mode 100644 payment/templates/gateways.mustache create mode 100644 payment/templates/gateways_modal.mustache create mode 100644 payment/templates/gateways_placeholder.mustache diff --git a/enrol/fee/classes/plugin.php b/enrol/fee/classes/plugin.php index 71b9e7e524a..f2d4200a6db 100644 --- a/enrol/fee/classes/plugin.php +++ b/enrol/fee/classes/plugin.php @@ -206,9 +206,12 @@ class enrol_fee_plugin extends enrol_plugin { echo '

'.get_string('loginsite').'

'; echo ''; } else { - echo '
'; - $PAGE->requires->js_call_amd('profilefield_conditional/conditionconfig', 'init', array('#id_param1', - '#profilefield_conditional_conditionconfiguration', '#id_conditionconfigbutton', $fieldid)); + \core_payment\helper::gateways_modal_requirejs(); + $attributes = core_payment\helper::gateways_modal_link_params($cost, $instance->currency); + + echo '
' . + html_writer::tag('button', get_string("sendpaymentbutton", "enrol_paypal"), $attributes) . + '
'; } } diff --git a/lang/en/payment.php b/lang/en/payment.php index a78b8ac7270..b9f6322e0f3 100644 --- a/lang/en/payment.php +++ b/lang/en/payment.php @@ -22,4 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string['nogateway'] = 'There is no payment gateway that can be used.'; +$string['selectpaymenttype'] = 'Select payment type'; $string['supportedcurrencies'] = 'Supported currencies'; diff --git a/payment/amd/build/gateways_modal.min.js b/payment/amd/build/gateways_modal.min.js new file mode 100644 index 0000000000000000000000000000000000000000..f6c364ccbe3f76d1535a4ecdf28c7d087c6fc902 GIT binary patch literal 3183 zcmai0ZExE)5dPj@A!~ynAu640z)(nKv!We_0_{39EA}DF0*X3WN@da`sicOi|Gwjk zWY_6B1c)Vy_rm9%dyaK4xM`(`Zq05BvQAh!#6Op;gl^S9w*{r6r;+~_7j2!yb+Cvj z^~=%KZd1x`xs0`YIQ>9c1Bw}`(jf$)lMfqBf$5b9AtE-8&}sPAPKJ>t2dA-?OGda9 z+NhpmL`vzD99vA!WUHi+HuuXZ<2;-Mqla`3aEukyt$-+rxm0kwWxEXsvsyC)4{WDz zH?m?~oL$H8c`KFCappFz-1=?JY#zI5(ZFWgq2;^_GY#Kn&kD9ux50|6G<0Bn%qHG3 z++!9xzR4yi5|))2&#DZvI$L8Edkqn~Z@Gz!_vIZrA^s@8D~WYAJG6*zZ$ZD4Ro_9J z4fm|;Azz%2X~Bqsb*r&*zt});?V~_4(0kcd(RoqQyQEADjz2stYW%6wVolp*jc*gD znj{^*pv+>T%%8wMy<^)npe_2YEAE+!7!~jkg|9_(Aj-@W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F6c=k#7reyS+TrYMrQRmoRDjcZ6b} zB^4>(mDFSP_dib^Sy9@8s(O##+yEP~DJo&ylqOU2eRUiF<~U&`;(zD2tyA?x(p#j`%hwoE+D3aODAZj?=r`@Y=}UHierQQMk& zHV1GdZ`+S5c9pZ7T-f&ftk&`)%+3~3CoZz}k5azA8rtReSxFmQDvDqx`_-Pcs!|FY zOddx`@e&7fe;k{a=y0>x^Fzu$9{r(fWzfQzozgmJ>6Otjq-8R(;4pHY zl=Q54DO;4DR~PSBG8V~?i;f9_?qI6WAxozLx`6rJZcYl|4f-eW_ywbT4|e4#-8=>& z)N=zI?I9G6Kk07dez*K&=xD!GKNi;q)} z{?k+%ddzK|Zn|%{OUzo@oF8 literal 0 HcmV?d00001 diff --git a/payment/amd/build/repository.min.js.map b/payment/amd/build/repository.min.js.map new file mode 100644 index 0000000000000000000000000000000000000000..00832a1a84aa5e7082e4e1e8133f872cd185909c GIT binary patch literal 1867 zcmah~ZBN@e6#gqm{lbPq!`RiX)D1L~wyaxAOJ9Z9Z@or*gw$rW`@!#(`PD(pz z+Kp7Zw$FL|oL4`!R>D}RRjczhXjxsESlCwQw$*Nj*2JL^rMA*(vuS^~t^1&*cu@^LzwA5zNjp5xaVmt%bV4||;3oC31usj~$E#cK zzOeN<3#u-=8V47QjaU#d{Ahf4PUA%|!*xV|uV@(HFgD#_#Mn3rt{M9h1p~&0bhg0Z zvWr9XEeaO(n)QNp#JYso!(9|51l&cb{^#JTft`{-mv;Lj97g`auR)KoAD)JxG5U(b z6wlF^#(j}iPAErS3`3Y_(!x^a0&p(5aiEtl(mKJNBgmX9J7HM(bz7S>yi=k7ZDmN? z2mw|v-I^QGfsL*p<_e5Rq;*CRIU!N*G3I6oy*zBW7NOSxsN8jd*Be z_nL@D{8;k%AD()_eYyIOtTZys9Kgx($uZ0_UdRGz{L3X0w|Aete^^}+jJed8*l ztd9s5j4$o9X^M4zQk|AYV^gK#_pY)r>n?_uk^1FU*drH@{e&ORP(ZUuK@WC(uG7*CpO5BZR{>79CY+i<&oeS3V5 WLL^A~OLG literal 0 HcmV?d00001 diff --git a/payment/amd/build/selectors.min.js b/payment/amd/build/selectors.min.js new file mode 100644 index 0000000000000000000000000000000000000000..de2f08e223cd935deabdfa1d4c84455568cd7d89 GIT binary patch literal 277 zcmYk%!D_=W41nQ#pTg5FDWply2|4Y$vQg-%EkU!@;F8!zmb-4trx>S;T#Yy7d8dTDOn8nyj5n3%ey5v!>~p-&v+i+6&{m0ZEm zpy1|DG$*)=jlPo;oME18CQ0nnBeNt|W%;b4PpoN&Az0TP_OH$3(_*l$xW;0@u=)lM C?PVeW literal 0 HcmV?d00001 diff --git a/payment/amd/build/selectors.min.js.map b/payment/amd/build/selectors.min.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f68775abafae22b1b363b7dce9239ce3c012f8c6 GIT binary patch literal 1302 zcmah}ZEu?}5dJGCzI3Z7Z0o0`TUC;#ZKgDdNTM!ks>y)^yn>Bv6P8u|?>hrYE3Mj) z5ZHJ3+;gu_&K8yCQaHU+*U_?45o)J*?|7cCRpe{TF)~tV@27SiTt~2?l`BliN;|HT zGJ`eS>46l6ae>O}6|5||ND0b${1()GbO*uUd*DukU`oHi(4NNwm-mB!_uCsi2rgs# zy(A&wc4RCp3S&9>J}fe>A>la!eM_bc$OLYsjOpeCGGoe~?-$M4lPdMs!f)QajaF;zgNrij;Dzm@qpc-$2|B!@&*N1pU!?v{+FL za5Y*?hVwaGO+yG^7KDq@U^xy#m@UKEbUyR|=9D8!MuYH=94Aek6he&Dfw_K(dqu_7 z#4wK`V_T#mN65Ftk3l3$%kDq*Yh1HjinNKfYa^mIN%G#>SU zt-toqi4CC~AFl-*!zCs(BETrgo$tehL5;7nPs0PU&1uPY1x)~zi)x#&2ni8dxC?5} zidx@3kyQAj(|wuS#_L7NqDPiCdau=5q0NNiX=VUEefanp<{2w^0U`cooPyKMkv!QU z^CDTCw`N_0*7Y0lThJU6N=dUEW5TN3z!M4R z>2^$Sf3|mjZJQn(-P7o>lUDod`mm5rqWwl%I}b. + +/** + * Contain the logic for the gateways modal. + * + * @module core_payment/gateways_modal + * @package core_payment + * @copyright 2019 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +import ModalFactory from 'core/modal_factory'; +import Templates from 'core/templates'; +import {get_string as getString} from 'core/str'; +import {getGatewaysSupportingCurrency} from 'core_payment/repository'; +import Selectors from './selectors'; +import * as ModalEvents from 'core/modal_events'; + +/** + * Register event listeners for the module. + * + * @param {string} nodeSelector The root to listen to. + */ +export const registerEventListeners = (nodeSelector) => { + const rootNode = document.querySelector(nodeSelector); + + rootNode.addEventListener('click', (e) => { + e.preventDefault(); + show(rootNode, {focusOnClose: e.target}); + }); +}; + +/** + * Shows the gateway selector modal. + * + * @param {HTMLElement} rootNode + * @param {Object} options - Additional options + * @param {HTMLElement} options.focusOnClose The element to focus on when the modal is closed. + */ +const show = (rootNode, { + focusOnClose = null, +} = {}) => { + Templates.render('core_payment/gateways_modal', {}) + .done(content => { + ModalFactory.create({ + title: getString('selectpaymenttype', 'core_payment'), + body: content, + }) + .done(function(modal) { + const currency = rootNode.dataset.currency; + getGatewaysSupportingCurrency(currency) + .done(gateways => { + const context = { + gateways: [] + }; + + for (let gateway of gateways) { + context.gateways.push(gateway); + } + + Templates.render('core_payment/gateways', context) + .done((html, js) => { + Templates.replaceNodeContents(modal.getRoot().find(Selectors.regions.gatewaysContainer), + html, js); + }); + }); + + modal.getRoot().on(ModalEvents.hidden, function() { + // Destroy when hidden. + modal.destroy(); + try { + focusOnClose.focus(); + } catch (e) { + // eslint-disable-line + } + }); + + modal.show(); + }); + }); +}; diff --git a/payment/amd/src/repository.js b/payment/amd/src/repository.js new file mode 100644 index 00000000000..758c80aa675 --- /dev/null +++ b/payment/amd/src/repository.js @@ -0,0 +1,41 @@ +// 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 . + +/** + * Repository for payment subsystem. + * + * @module core_payment/repository + * @package core_payment + * @copyright 2020 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +import Ajax from 'core/ajax'; + +/** + * Returns the list of gateways that can process payments in the given currency. + * + * @param {string} currency The currency in the three-character ISO-4217 format + * @returns {Promise<{shortname: string, name: string, description: String}[]>} + */ +export const getGatewaysSupportingCurrency = currency => { + const request = { + methodname: 'core_payment_get_gateways_for_currency', + args: { + currency + } + }; + return Ajax.call([request])[0]; +}; diff --git a/payment/amd/src/selectors.js b/payment/amd/src/selectors.js new file mode 100644 index 00000000000..35be2db2265 --- /dev/null +++ b/payment/amd/src/selectors.js @@ -0,0 +1,29 @@ +// 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 . + +/** + * Define all of the selectors we will be using on the payment interface. + * + * @module core_payment/selectors + * @package core_payment + * @copyright 2019 Shamim Rezaie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +export default { + regions: { + gatewaysContainer: '[data-region="gateways-container"]', + }, +}; diff --git a/payment/classes/helper.php b/payment/classes/helper.php index 4e611d99e91..1fb92612a70 100644 --- a/payment/classes/helper.php +++ b/payment/classes/helper.php @@ -75,4 +75,35 @@ class helper { return $gateways; } + + /** + * Requires the JS libraries for the pay button. + */ + public static function gateways_modal_requirejs(): void { + global $PAGE; + + static $done = false; + if ($done) { + return; + } + + $PAGE->requires->js_call_amd('core_payment/gateways_modal', 'registerEventListeners', ['#gateways-modal-trigger']); + $done = true; + } + + /** + * Returns the attributes to place on a pay button. + * + * @param float $amount Amount of payment + * @param string $currency Currency of payment + * @return array + */ + public static function gateways_modal_link_params(float $amount, string $currency) : array { + return [ + 'id' => 'gateways-modal-trigger', + 'role' => 'button', + 'data-amount' => $amount, + 'data-currency' => $currency, + ]; + } } diff --git a/payment/templates/gateway.mustache b/payment/templates/gateway.mustache new file mode 100644 index 00000000000..a363f80f5f6 --- /dev/null +++ b/payment/templates/gateway.mustache @@ -0,0 +1,48 @@ +{{! + 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 . +}} +{{! + @template core_payment/gateway + + This template will render the gateway option in the gateway selector modal. + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * shortname + * name + * description + * image + + Example context (json): + { + "shortname": "paypal", + "name": "PayPal", + "description": "A description for PayPal.", + } + +}} +
+ + +
\ No newline at end of file diff --git a/payment/templates/gateways.mustache b/payment/templates/gateways.mustache new file mode 100644 index 00000000000..c2c1a39c503 --- /dev/null +++ b/payment/templates/gateways.mustache @@ -0,0 +1,55 @@ +{{! + 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 . +}} +{{! + @template core_payment/gateways + + This template will render the list of gateways in the gateway selector modal. + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * gateways + + Example context (json): + { + "gateways" : [ + { + "shortname": "paypal", + "name": "PayPal", + "description": "A description for PayPal.", + "image": "../../../pix/help.svg" + }, + { + "shortname": "stripe", + "name": "Stripe", + "description": "A description for Stripe.", + "image": "../../../pix/help.svg" + } + ] + } + +}} +{{#gateways}} + {{> core_payment/gateway }} +{{/gateways}} +{{^gateways}} +

{{#str}}nogateway, core_payment{{/str}}

+{{/gateways}} \ No newline at end of file diff --git a/payment/templates/gateways_modal.mustache b/payment/templates/gateways_modal.mustache new file mode 100644 index 00000000000..9de46c4df89 --- /dev/null +++ b/payment/templates/gateways_modal.mustache @@ -0,0 +1,37 @@ +{{! + 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 . +}} +{{! + @template core_payment/gateways_modal + + This template will render the gateway selector modal. + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * none + + Example context (json): + {} + +}} +
+ {{> core_payment/gateways_placeholder }} +
\ No newline at end of file diff --git a/payment/templates/gateways_placeholder.mustache b/payment/templates/gateways_placeholder.mustache new file mode 100644 index 00000000000..ad7a549fcf9 --- /dev/null +++ b/payment/templates/gateways_placeholder.mustache @@ -0,0 +1,41 @@ +{{! + 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 . +}} +{{! + @template core_payment/gateways_placeholder + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * none + + Example context (json): + {} + +}} +
+ + +
\ No newline at end of file -- 2.43.0