Skip to content

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

feat: fix plan null

Marc Seitzc7bc5d13c737
diff --git a/ee/stripe/functions/get-quantity-from-plan.ts b/ee/stripe/functions/get-quantity-from-plan.ts
index 33ea6238..a1c9893f 100644
--- a/ee/stripe/functions/get-quantity-from-plan.ts
+++ b/ee/stripe/functions/get-quantity-from-plan.ts
@@ -6,7 +6,7 @@ export function getQuantityFromPriceId(priceId?: string) {
}
try {
const plan = getPlanFromPriceId(priceId);
- return plan.minQuantity ?? 1;
+ return plan?.minQuantity ?? 1;
} catch (error) {
console.error("Error getting quantity for priceId: %s", priceId, error);
return 1;
diff --git a/pages/api/teams/[teamId]/billing/upgrade.ts b/pages/api/teams/[teamId]/billing/upgrade.ts
index 42fa9916..d168ac57 100644
--- a/pages/api/teams/[teamId]/billing/upgrade.ts
+++ b/pages/api/teams/[teamId]/billing/upgrade.ts
@@ -54,6 +54,12 @@ export default async function handle(
const oldAccount = isOldAccount(team.plan);
const plan = getPlanFromPriceId(priceId, oldAccount);
+
+ if (!plan) {
+ res.status(400).json({ error: "Invalid price ID" });
+ return;
+ }
+
const minimumQuantity = plan.minQuantity;
let stripeSession;