mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-03 09:16:40 +00:00
Compare commits
2 Commits
1.15.3-s.0
...
1.15.3-s.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98a4c453c1 | ||
|
|
6475dceab9 |
@@ -56,22 +56,22 @@ export function getFeatureIdByMetricId(
|
|||||||
|
|
||||||
export type FeaturePriceSet = Partial<Record<FeatureId, string>>;
|
export type FeaturePriceSet = Partial<Record<FeatureId, string>>;
|
||||||
|
|
||||||
export const homeLabFeaturePriceSet: FeaturePriceSet = {
|
export const tier1FeaturePriceSet: FeaturePriceSet = {
|
||||||
[FeatureId.TIER1]: "price_1SzVE3D3Ee2Ir7Wm6wT5Dl3G"
|
[FeatureId.TIER1]: "price_1SzVE3D3Ee2Ir7Wm6wT5Dl3G"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const homeLabFeaturePriceSetSandbox: FeaturePriceSet = {
|
export const tier1FeaturePriceSetSandbox: FeaturePriceSet = {
|
||||||
[FeatureId.TIER1]: "price_1SxgpPDCpkOb237Bfo4rIsoT"
|
[FeatureId.TIER1]: "price_1SxgpPDCpkOb237Bfo4rIsoT"
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getHomeLabFeaturePriceSet(): FeaturePriceSet {
|
export function getTier1FeaturePriceSet(): FeaturePriceSet {
|
||||||
if (
|
if (
|
||||||
process.env.ENVIRONMENT == "prod" &&
|
process.env.ENVIRONMENT == "prod" &&
|
||||||
process.env.SANDBOX_MODE !== "true"
|
process.env.SANDBOX_MODE !== "true"
|
||||||
) {
|
) {
|
||||||
return homeLabFeaturePriceSet;
|
return tier1FeaturePriceSet;
|
||||||
} else {
|
} else {
|
||||||
return homeLabFeaturePriceSetSandbox;
|
return tier1FeaturePriceSetSandbox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ export const tier2FeaturePriceSetSandbox: FeaturePriceSet = {
|
|||||||
[FeatureId.USERS]: "price_1SxaEHDCpkOb237BD9lBkPiR"
|
[FeatureId.USERS]: "price_1SxaEHDCpkOb237BD9lBkPiR"
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getStarterFeaturePriceSet(): FeaturePriceSet {
|
export function getTier2FeaturePriceSet(): FeaturePriceSet {
|
||||||
if (
|
if (
|
||||||
process.env.ENVIRONMENT == "prod" &&
|
process.env.ENVIRONMENT == "prod" &&
|
||||||
process.env.SANDBOX_MODE !== "true"
|
process.env.SANDBOX_MODE !== "true"
|
||||||
@@ -102,7 +102,7 @@ export const tier3FeaturePriceSetSandbox: FeaturePriceSet = {
|
|||||||
[FeatureId.USERS]: "price_1SxaEODCpkOb237BiXdCBSfs"
|
[FeatureId.USERS]: "price_1SxaEODCpkOb237BiXdCBSfs"
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getScaleFeaturePriceSet(): FeaturePriceSet {
|
export function getTier3FeaturePriceSet(): FeaturePriceSet {
|
||||||
if (
|
if (
|
||||||
process.env.ENVIRONMENT == "prod" &&
|
process.env.ENVIRONMENT == "prod" &&
|
||||||
process.env.SANDBOX_MODE !== "true"
|
process.env.SANDBOX_MODE !== "true"
|
||||||
@@ -116,9 +116,9 @@ export function getScaleFeaturePriceSet(): FeaturePriceSet {
|
|||||||
export function getFeatureIdByPriceId(priceId: string): FeatureId | undefined {
|
export function getFeatureIdByPriceId(priceId: string): FeatureId | undefined {
|
||||||
// Check all feature price sets
|
// Check all feature price sets
|
||||||
const allPriceSets = [
|
const allPriceSets = [
|
||||||
getHomeLabFeaturePriceSet(),
|
getTier1FeaturePriceSet(),
|
||||||
getStarterFeaturePriceSet(),
|
getTier2FeaturePriceSet(),
|
||||||
getScaleFeaturePriceSet()
|
getTier3FeaturePriceSet()
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const priceSet of allPriceSets) {
|
for (const priceSet of allPriceSets) {
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ import logger from "@server/logger";
|
|||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import stripe from "#private/lib/stripe";
|
import stripe from "#private/lib/stripe";
|
||||||
import {
|
import {
|
||||||
getHomeLabFeaturePriceSet,
|
getTier1FeaturePriceSet,
|
||||||
getScaleFeaturePriceSet,
|
getTier3FeaturePriceSet,
|
||||||
getStarterFeaturePriceSet,
|
getTier2FeaturePriceSet,
|
||||||
FeatureId,
|
FeatureId,
|
||||||
type FeaturePriceSet
|
type FeaturePriceSet
|
||||||
} from "@server/lib/billing";
|
} from "@server/lib/billing";
|
||||||
@@ -113,11 +113,11 @@ export async function changeTier(
|
|||||||
// Get the target tier's price set
|
// Get the target tier's price set
|
||||||
let targetPriceSet: FeaturePriceSet;
|
let targetPriceSet: FeaturePriceSet;
|
||||||
if (tier === "tier1") {
|
if (tier === "tier1") {
|
||||||
targetPriceSet = getHomeLabFeaturePriceSet();
|
targetPriceSet = getTier1FeaturePriceSet();
|
||||||
} else if (tier === "tier2") {
|
} else if (tier === "tier2") {
|
||||||
targetPriceSet = getStarterFeaturePriceSet();
|
targetPriceSet = getTier2FeaturePriceSet();
|
||||||
} else if (tier === "tier3") {
|
} else if (tier === "tier3") {
|
||||||
targetPriceSet = getScaleFeaturePriceSet();
|
targetPriceSet = getTier3FeaturePriceSet();
|
||||||
} else {
|
} else {
|
||||||
return next(createHttpError(HttpCode.BAD_REQUEST, "Invalid tier"));
|
return next(createHttpError(HttpCode.BAD_REQUEST, "Invalid tier"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import config from "@server/lib/config";
|
|||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import stripe from "#private/lib/stripe";
|
import stripe from "#private/lib/stripe";
|
||||||
import {
|
import {
|
||||||
getHomeLabFeaturePriceSet,
|
getTier1FeaturePriceSet,
|
||||||
getScaleFeaturePriceSet,
|
getTier3FeaturePriceSet,
|
||||||
getStarterFeaturePriceSet
|
getTier2FeaturePriceSet
|
||||||
} from "@server/lib/billing";
|
} from "@server/lib/billing";
|
||||||
import { getLineItems } from "@server/lib/billing/getLineItems";
|
import { getLineItems } from "@server/lib/billing/getLineItems";
|
||||||
import Stripe from "stripe";
|
import Stripe from "stripe";
|
||||||
@@ -88,11 +88,11 @@ export async function createCheckoutSession(
|
|||||||
|
|
||||||
let lineItems: Stripe.Checkout.SessionCreateParams.LineItem[];
|
let lineItems: Stripe.Checkout.SessionCreateParams.LineItem[];
|
||||||
if (tier === "tier1") {
|
if (tier === "tier1") {
|
||||||
lineItems = await getLineItems(getHomeLabFeaturePriceSet(), orgId);
|
lineItems = await getLineItems(getTier1FeaturePriceSet(), orgId);
|
||||||
} else if (tier === "tier2") {
|
} else if (tier === "tier2") {
|
||||||
lineItems = await getLineItems(getStarterFeaturePriceSet(), orgId);
|
lineItems = await getLineItems(getTier2FeaturePriceSet(), orgId);
|
||||||
} else if (tier === "tier3") {
|
} else if (tier === "tier3") {
|
||||||
lineItems = await getLineItems(getScaleFeaturePriceSet(), orgId);
|
lineItems = await getLineItems(getTier3FeaturePriceSet(), orgId);
|
||||||
} else {
|
} else {
|
||||||
return next(createHttpError(HttpCode.BAD_REQUEST, "Invalid plan"));
|
return next(createHttpError(HttpCode.BAD_REQUEST, "Invalid plan"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import {
|
|||||||
getLicensePriceSet,
|
getLicensePriceSet,
|
||||||
} from "@server/lib/billing/licenses";
|
} from "@server/lib/billing/licenses";
|
||||||
import {
|
import {
|
||||||
getHomeLabFeaturePriceSet,
|
getTier1FeaturePriceSet,
|
||||||
getStarterFeaturePriceSet,
|
getTier2FeaturePriceSet,
|
||||||
getScaleFeaturePriceSet,
|
getTier3FeaturePriceSet,
|
||||||
} from "@server/lib/billing/features";
|
} from "@server/lib/billing/features";
|
||||||
import Stripe from "stripe";
|
import Stripe from "stripe";
|
||||||
import { Tier } from "@server/types/Tiers";
|
import { Tier } from "@server/types/Tiers";
|
||||||
@@ -40,19 +40,19 @@ export function getSubType(fullSubscription: Stripe.Response<Stripe.Subscription
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if price ID matches home lab tier
|
// Check if price ID matches home lab tier
|
||||||
const homeLabPrices = Object.values(getHomeLabFeaturePriceSet());
|
const homeLabPrices = Object.values(getTier1FeaturePriceSet());
|
||||||
if (homeLabPrices.includes(priceId)) {
|
if (homeLabPrices.includes(priceId)) {
|
||||||
return "tier1";
|
return "tier1";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if price ID matches tier2 tier
|
// Check if price ID matches tier2 tier
|
||||||
const tier2Prices = Object.values(getStarterFeaturePriceSet());
|
const tier2Prices = Object.values(getTier2FeaturePriceSet());
|
||||||
if (tier2Prices.includes(priceId)) {
|
if (tier2Prices.includes(priceId)) {
|
||||||
return "tier2";
|
return "tier2";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if price ID matches tier3 tier
|
// Check if price ID matches tier3 tier
|
||||||
const tier3Prices = Object.values(getScaleFeaturePriceSet());
|
const tier3Prices = Object.values(getTier3FeaturePriceSet());
|
||||||
if (tier3Prices.includes(priceId)) {
|
if (tier3Prices.includes(priceId)) {
|
||||||
return "tier3";
|
return "tier3";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ export async function validateOidcCallback(
|
|||||||
allOrgs[0].orgId,
|
allOrgs[0].orgId,
|
||||||
tierMatrix.autoProvisioning
|
tierMatrix.autoProvisioning
|
||||||
);
|
);
|
||||||
if (subscribed) {
|
if (!subscribed) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.FORBIDDEN,
|
HttpCode.FORBIDDEN,
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export async function createOrgUser(
|
|||||||
orgId,
|
orgId,
|
||||||
tierMatrix.orgOidc
|
tierMatrix.orgOidc
|
||||||
);
|
);
|
||||||
if (subscribed) {
|
if (!subscribed) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.FORBIDDEN,
|
HttpCode.FORBIDDEN,
|
||||||
|
|||||||
Reference in New Issue
Block a user