Fix resubscription of servers with failed payments (#3696)

* Fix resubscription of servers with failed payments

Resolves MOD-55

* run fix
This commit is contained in:
Emma Alexia
2025-05-25 15:36:14 -04:00
committed by GitHub
parent dc0d923cee
commit 84adf79564
2 changed files with 34 additions and 6 deletions

View File

@@ -361,7 +361,14 @@
"
color="green"
>
<button @click="resubscribePyro(subscription.id)">
<button
@click="
resubscribePyro(
subscription.id,
$dayjs(getPyroCharge(subscription).due).isBefore($dayjs()),
)
"
>
Resubscribe <RightArrowIcon />
</button>
</ButtonStyled>
@@ -1098,7 +1105,7 @@ async function fetchCapacityStatuses(serverId, product) {
}
}
const resubscribePyro = async (subscriptionId) => {
const resubscribePyro = async (subscriptionId, wasSuspended) => {
try {
await useBaseFetch(`billing/subscription/${subscriptionId}`, {
internal: true,
@@ -1108,6 +1115,21 @@ const resubscribePyro = async (subscriptionId) => {
},
});
await refresh();
if (wasSuspended) {
data.$notify({
group: "main",
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",
});
} else {
data.$notify({
group: "main",
title: "Success",
text: "Server subscription resubscribed successfully",
type: "success",
});
}
} catch {
data.$notify({
group: "main",