diff --git a/apps/frontend/src/pages/admin/billing/[id].vue b/apps/frontend/src/pages/admin/billing/[id].vue
index fbbaae9c6..4bded6a5f 100644
--- a/apps/frontend/src/pages/admin/billing/[id].vue
+++ b/apps/frontend/src/pages/admin/billing/[id].vue
@@ -58,6 +58,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -234,7 +275,6 @@ import { products } from "~/generated/state.json";
import ModrinthServersIcon from "~/components/ui/servers/ModrinthServersIcon.vue";
const route = useRoute();
-const data = useNuxtApp();
const vintl = useVIntl();
const { formatMessage } = vintl;
@@ -304,6 +344,10 @@ const refundTypes = ref(["full", "partial", "none"]);
const refundAmount = ref(0);
const unprovision = ref(true);
+const modifying = ref(false);
+const modifyModal = ref();
+const cancel = ref(false);
+
function showRefundModal(charge) {
selectedCharge.value = charge;
refundType.value = "full";
@@ -312,6 +356,12 @@ function showRefundModal(charge) {
refundModal.value.show();
}
+function showModifyModal(charge) {
+ selectedCharge.value = charge;
+ cancel.value = false;
+ modifyModal.value.show();
+}
+
async function refundCharge() {
refunding.value = true;
try {
@@ -327,8 +377,7 @@ async function refundCharge() {
await refreshCharges();
refundModal.value.hide();
} catch (err) {
- data.$notify({
- group: "main",
+ addNotification({
title: "Error refunding",
text: err.data?.description ?? err,
type: "error",
@@ -337,6 +386,32 @@ async function refundCharge() {
refunding.value = false;
}
+async function modifyCharge() {
+ modifying.value = true;
+ try {
+ await useBaseFetch(`billing/subscription/${selectedCharge.value.id}`, {
+ method: "PATCH",
+ body: JSON.stringify({
+ cancelled: cancel.value,
+ }),
+ internal: true,
+ });
+ addNotification({
+ title: "Resubscription request submitted",
+ text: "If the server is currently suspended, it may take up to 10 minutes for another charge attempt to be made.",
+ type: "success",
+ });
+ await refreshCharges();
+ } catch (err) {
+ addNotification({
+ title: "Error reattempting charge",
+ text: err.data?.description ?? err,
+ type: "error",
+ });
+ }
+ modifying.value = false;
+}
+
const chargeStatuses = {
open: {
color: "bg-blue",
diff --git a/apps/labrinth/src/routes/internal/billing.rs b/apps/labrinth/src/routes/internal/billing.rs
index a5fcbc176..49e50eac7 100644
--- a/apps/labrinth/src/routes/internal/billing.rs
+++ b/apps/labrinth/src/routes/internal/billing.rs
@@ -276,7 +276,11 @@ pub async fn refund_charge(
subscription_interval: charge.subscription_interval,
payment_platform: charge.payment_platform,
payment_platform_id: id,
- parent_charge_id: Some(charge.id),
+ parent_charge_id: if refund_amount != 0 {
+ Some(charge.id)
+ } else {
+ None
+ },
net,
}
.upsert(&mut transaction)