MDL-69166 core_payment: display the gateways modal

This commit is contained in:
Shamim Rezaie
2020-10-27 15:44:58 +11:00
parent f3d7526419
commit c2321a263b
16 changed files with 393 additions and 3 deletions
+31
View File
@@ -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,
];
}
}