Skip to content

Commit

Permalink
MDL-69166 core_payment: improvements to api, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy authored and rezaies committed Oct 27, 2020
1 parent 6ff3087 commit 1d479dc
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 92 deletions.
3 changes: 2 additions & 1 deletion enrol/fee/classes/payment/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ public static function get_cost(int $instanceid): array {
* Callback function that delivers what the user paid for to them.
*
* @param int $instanceid The enrolment instance id
* @param int $paymentid payment id as inserted into the 'payments' table, if needed for reference
* @return bool Whether successful or not
*/
public static function deliver_order(int $instanceid): bool {
public static function deliver_order(int $instanceid, int $paymentid): bool {
global $DB, $USER;

$instance = $DB->get_record('enrol', ['enrol' => 'fee', 'id' => $instanceid], '*', MUST_EXIST);
Expand Down
9 changes: 1 addition & 8 deletions enrol/fee/classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,9 @@ public function enrol_page_hook(stdClass $instance) {
echo '<p>'.get_string('nocost', 'enrol_fee').'</p>';
} else {

$locale = get_string('localecldr', 'langconfig');
$fmt = NumberFormatter::create($locale, NumberFormatter::CURRENCY);
$localisedcost = numfmt_format_currency($fmt, $cost, $instance->currency);

$data = [
'isguestuser' => isguestuser(),
'cost' => $localisedcost,
'currency' => $instance->currency,
'accountid' => $instance->customint1,
'amount' => $cost,
'cost' => \core_payment\helper::get_cost_as_string($instance->cost, $instance->currency),
'instanceid' => $instance->id,
'description' => get_string('purchasedescription', 'enrol_fee',
format_string($course->fullname, true, ['context' => $context])),
Expand Down
4 changes: 0 additions & 4 deletions enrol/fee/templates/payment_region.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"cost": "$108.50",
"amount": 108.50,
"currency": "AUD",
"accountid": 1,
"instanceid": 11,
"description": "Enrolment in course Introduction to algorithms",
"isguestuser": false
Expand All @@ -63,9 +62,6 @@
class="btn btn-secondary"
type="button"
id="gateways-modal-trigger-{{ uniqid }}"
data-amount="{{amount}}"
data-currency="{{currency}}"
data-accountid="{{accountid}}"
data-component="enrol_fee"
data-componentid="{{instanceid}}"
data-description={{# quote }}{{description}}{{/ quote }}
Expand Down
2 changes: 1 addition & 1 deletion payment/amd/build/gateways_modal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1d479dc

Please sign in to comment.