Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: improve

Marc Seitz685484c80658
diff --git a/ee/features/billing/cancellation/api/unpause-route.ts b/ee/features/billing/cancellation/api/unpause-route.ts
index 9e8de038..6c43b01d 100644
--- a/ee/features/billing/cancellation/api/unpause-route.ts
+++ b/ee/features/billing/cancellation/api/unpause-route.ts
@@ -60,14 +60,14 @@ export async function handleRoute(req: NextApiRequest, res: NextApiResponse) {
return res.status(400).json({ error: "No subscription ID" });
}
+ if (!team.pauseStartsAt || !team.pauseEndsAt) {
+ return res.status(400).json({ error: "Subscription is not paused" });
+ }
+
const isOldAccount = team.plan.includes("+old");
const stripe = stripeInstance(isOldAccount);
- const pauseStartsAt = team.endsAt ? new Date(team.endsAt) : new Date();
- const pauseEndsAt = new Date(pauseStartsAt);
- pauseEndsAt.setDate(pauseStartsAt.getDate() + 90);
-
- // Pause the subscription in Stripe
+ // Unpause the subscription in Stripe
await stripe.subscriptions.update(team.subscriptionId, {
pause_collection: "",
});
@@ -102,15 +102,15 @@ export async function handleRoute(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({
success: true,
- message: "Subscription paused successfully",
+ message: "Subscription unpaused successfully",
});
} catch (error) {
- console.error("Error pausing subscription:", error);
+ console.error("Error unpausing subscription:", error);
await log({
- message: `Error pausing subscription for team ${teamId}: ${error}`,
+ message: `Error unpausing subscription for team ${teamId}: ${error}`,
type: "error",
});
- res.status(500).json({ error: "Failed to pause subscription" });
+ res.status(500).json({ error: "Failed to unpause subscription" });
}
} else {
res.setHeader("Allow", ["POST"]);
diff --git a/ee/features/billing/cancellation/components/pause-subscription-modal.tsx b/ee/features/billing/cancellation/components/pause-subscription-modal.tsx
index a4b94e06..08ea5e42 100644
--- a/ee/features/billing/cancellation/components/pause-subscription-modal.tsx
+++ b/ee/features/billing/cancellation/components/pause-subscription-modal.tsx
@@ -54,6 +54,10 @@ export function PauseSubscriptionModal({
throw new Error("Failed to pause subscription");
}
+ const pauseStartsAt = endsAt ? new Date(endsAt) : new Date();
+ const pauseEndsAt = new Date(pauseStartsAt);
+ pauseEndsAt.setDate(pauseStartsAt.getDate() + 90);
+
// Track the pause event for analytics
analytics.capture("Subscription Paused", {
teamId: currentTeamId,
diff --git a/ee/features/billing/cancellation/components/schedule-call-modal.tsx b/ee/features/billing/cancellation/components/schedule-call-modal.tsx
index 0a212591..cdb79f69 100644
--- a/ee/features/billing/cancellation/components/schedule-call-modal.tsx
+++ b/ee/features/billing/cancellation/components/schedule-call-modal.tsx
@@ -80,7 +80,7 @@ export function ScheduleCallModal({
{calLoaded ? (
<Cal
namespace="papermark-support"
- calLink={`marcseitz/papermark-support?email=${session?.user?.email}&name=${session?.user?.name}`}
+ calLink={`marcseitz/papermark-support?email=${session?.user?.email || ""}&name=${session?.user?.name || ""}`}
style={{
width: "100%",
height: "540px",