'instanceid' => $instance->id,
'description' => get_string('purchasedescription', 'enrol_fee',
format_string($course->fullname, true, ['context' => $context])),
+ 'successurl' => \enrol_fee\payment\service_provider::get_success_url('fee', $instance->id)->out(false),
];
echo $OUTPUT->render_from_template('enrol_fee/payment_region', $data);
}
* data-itemid
* data-cost
* data-description
+ * data-successurl
Context variables required for this template:
* cost - Human readable cost string including amount and currency
* instanceid - Id of the enrolment instance
* description - The description for this purchase
+ * successurl - The URL of the course
Example context (json):
{
"cost": "$108.50",
"instanceid": 11,
"description": "Enrolment in course Introduction to algorithms",
+ "successurl": "https://moodlesite/course/view.php?id=2",
"isguestuser": false
}
data-paymentarea="fee"
data-itemid="{{instanceid}}"
data-cost="{{cost}}"
+ data-successurl="{{successurl}}"
data-description={{# quote }}{{description}}{{/ quote }}
>
{{# str }} sendpaymentbutton, enrol_fee {{/ str }}
message: message,
type: 'success',
});
- location.reload();
+ location.href = rootNode.dataset.successurl;
// The following return statement is never reached. It is put here just to make eslint happy.
return message;
/**
* Returns the attributes to place on a pay button.
*
- * @param string $component Name of the component that the itemid belongs to
- * @param string $paymentarea
+ * @param string $component Name of the component that the paymentarea and itemid belong to
+ * @param string $paymentarea Payment area
* @param int $itemid An internal identifier that is used by the component
* @param string $description Description of the payment
* @return array
string $description): array {
$payable = static::get_payable($component, $paymentarea, $itemid);
+ $successurl = static::get_success_url($component, $paymentarea, $itemid);
return [
'id' => 'gateways-modal-trigger',
'data-itemid' => $itemid,
'data-cost' => static::get_cost_as_string($payable->get_amount(), $payable->get_currency()),
'data-description' => $description,
+ 'data-successurl' => $successurl->out(false),
];
}