mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-03-05 00:59:26 +00:00
An implementation of refunds from the Admin dashboard. To refund, go to Plugins > Subscriptions > Subscriptions then click the `Cancel` button. You'll be presented with a modal. If you wish to refund only the most recent payment, check the box. This only implements refunds for Subscriptions, not One Time Payments. One Time Payments will still need to be handled manually at this time.
32 lines
905 B
JavaScript
32 lines
905 B
JavaScript
import I18n from "I18n";
|
|
import Route from "@ember/routing/route";
|
|
import AdminSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/admin-subscription";
|
|
|
|
export default Route.extend({
|
|
model() {
|
|
return AdminSubscription.find();
|
|
},
|
|
|
|
actions: {
|
|
cancelSubscription(model) {
|
|
const subscription = model.subscription;
|
|
const refund = model.refund;
|
|
subscription.set("loading", true);
|
|
subscription
|
|
.destroy(refund)
|
|
.then((result) => {
|
|
subscription.set("status", result.status);
|
|
this.send("closeModal");
|
|
bootbox.alert(I18n.t("discourse_subscriptions.admin.canceled"));
|
|
})
|
|
.catch((data) =>
|
|
bootbox.alert(data.jqXHR.responseJSON.errors.join("\n"))
|
|
)
|
|
.finally(() => {
|
|
subscription.set("loading", false);
|
|
this.refresh();
|
|
});
|
|
},
|
|
},
|
|
});
|