Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+39
@@ -0,0 +1,39 @@
|
||||
import { BillingPeriodDto } from "../dtos/subscriptions/BillingPeriodDto";
|
||||
import { SubscriptionBillingPeriod } from "../enums/subscriptions/SubscriptionBillingPeriod";
|
||||
|
||||
const billingPeriods: BillingPeriodDto[] = [
|
||||
{
|
||||
value: SubscriptionBillingPeriod.ONCE,
|
||||
recurring: false,
|
||||
},
|
||||
{
|
||||
value: SubscriptionBillingPeriod.MONTHLY,
|
||||
default: true,
|
||||
recurring: true,
|
||||
},
|
||||
{
|
||||
value: SubscriptionBillingPeriod.QUARTERLY,
|
||||
disabled: false,
|
||||
recurring: true,
|
||||
},
|
||||
{
|
||||
value: SubscriptionBillingPeriod.SEMI_ANNUAL,
|
||||
disabled: false,
|
||||
recurring: true,
|
||||
},
|
||||
{
|
||||
value: SubscriptionBillingPeriod.YEARLY,
|
||||
recurring: true,
|
||||
},
|
||||
{
|
||||
value: SubscriptionBillingPeriod.DAILY,
|
||||
disabled: true,
|
||||
recurring: true,
|
||||
},
|
||||
{
|
||||
value: SubscriptionBillingPeriod.WEEKLY,
|
||||
disabled: true,
|
||||
recurring: true,
|
||||
},
|
||||
];
|
||||
export default billingPeriods;
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import currencies from "./currencies";
|
||||
import { CurrencyDto } from "../dtos/subscriptions/CurrencyDto";
|
||||
|
||||
describe("currencies", () => {
|
||||
it("should contain the correct list of currencies", () => {
|
||||
const expectedCurrencies: CurrencyDto[] = [
|
||||
{
|
||||
name: "United States Dollar",
|
||||
value: "usd",
|
||||
symbol: "$",
|
||||
default: true,
|
||||
disabled: false,
|
||||
parities: [{ from: "usd", parity: 1 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Euro",
|
||||
value: "eur",
|
||||
symbol: "€",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1 }],
|
||||
symbolRight: true,
|
||||
thousandSeparator: ".",
|
||||
decimalSeparator: ",",
|
||||
},
|
||||
{
|
||||
name: "Great Britain Pound",
|
||||
value: "gbp",
|
||||
symbol: "£",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 0.85 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Indian Rupee",
|
||||
value: "inr",
|
||||
symbol: "₹",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 79.96 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Mexican Peso",
|
||||
value: "mxn",
|
||||
symbol: "$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 16.98 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Canadian Dollar",
|
||||
value: "cad",
|
||||
symbol: "C$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1.3 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Japanese Yen",
|
||||
value: "jpy",
|
||||
symbol: "¥",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 110 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Australian Dollar",
|
||||
value: "aud",
|
||||
symbol: "A$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1.4 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Swiss Franc",
|
||||
value: "chf",
|
||||
symbol: "CHF",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 0.92 }],
|
||||
symbolRight: true,
|
||||
thousandSeparator: "'",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Chinese Yuan",
|
||||
value: "cny",
|
||||
symbol: "¥",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 6.36 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "South Korean Won",
|
||||
value: "krw",
|
||||
symbol: "₩",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1190 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Russian Ruble",
|
||||
value: "rub",
|
||||
symbol: "₽",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 76 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: " ",
|
||||
decimalSeparator: ",",
|
||||
},
|
||||
{
|
||||
name: "Brazilian Real",
|
||||
value: "brl",
|
||||
symbol: "R$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 5.2 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ".",
|
||||
decimalSeparator: ",",
|
||||
},
|
||||
{
|
||||
name: "South African Rand",
|
||||
value: "zar",
|
||||
symbol: "R",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 15 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
];
|
||||
|
||||
expect(currencies).toHaveLength(expectedCurrencies.length);
|
||||
|
||||
currencies.forEach((currency, index) => {
|
||||
const expectedCurrency = expectedCurrencies[index];
|
||||
expect(currency).toMatchObject(expectedCurrency);
|
||||
});
|
||||
});
|
||||
});
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
import { CurrencyDto } from "../dtos/subscriptions/CurrencyDto";
|
||||
|
||||
const currencies: CurrencyDto[] = [
|
||||
{
|
||||
name: "United States Dollar",
|
||||
value: "usd",
|
||||
symbol: "$",
|
||||
default: true,
|
||||
disabled: false,
|
||||
parities: [{ from: "usd", parity: 1 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Euro",
|
||||
value: "eur",
|
||||
symbol: "€",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1 }],
|
||||
symbolRight: true,
|
||||
thousandSeparator: ".",
|
||||
decimalSeparator: ",",
|
||||
},
|
||||
{
|
||||
name: "Great Britain Pound",
|
||||
value: "gbp",
|
||||
symbol: "£",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 0.85 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Indian Rupee",
|
||||
value: "inr",
|
||||
symbol: "₹",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 79.96 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Mexican Peso",
|
||||
value: "mxn",
|
||||
symbol: "$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 16.98 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Canadian Dollar",
|
||||
value: "cad",
|
||||
symbol: "C$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1.3 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Japanese Yen",
|
||||
value: "jpy",
|
||||
symbol: "¥",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 110 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Australian Dollar",
|
||||
value: "aud",
|
||||
symbol: "A$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1.4 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Swiss Franc",
|
||||
value: "chf",
|
||||
symbol: "CHF",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 0.92 }],
|
||||
symbolRight: true,
|
||||
thousandSeparator: "'",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Chinese Yuan",
|
||||
value: "cny",
|
||||
symbol: "¥",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 6.36 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "South Korean Won",
|
||||
value: "krw",
|
||||
symbol: "₩",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 1190 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
{
|
||||
name: "Russian Ruble",
|
||||
value: "rub",
|
||||
symbol: "₽",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 76 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: " ",
|
||||
decimalSeparator: ",",
|
||||
},
|
||||
{
|
||||
name: "Brazilian Real",
|
||||
value: "brl",
|
||||
symbol: "R$",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 5.2 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ".",
|
||||
decimalSeparator: ",",
|
||||
},
|
||||
{
|
||||
name: "South African Rand",
|
||||
value: "zar",
|
||||
symbol: "R",
|
||||
disabled: true,
|
||||
parities: [{ from: "usd", parity: 15 }],
|
||||
symbolRight: false,
|
||||
thousandSeparator: ",",
|
||||
decimalSeparator: ".",
|
||||
},
|
||||
];
|
||||
export default currencies;
|
||||
+331
@@ -0,0 +1,331 @@
|
||||
import { SubscriptionBillingPeriod } from "~/application/enums/subscriptions/SubscriptionBillingPeriod";
|
||||
import { SubscriptionPriceType } from "~/application/enums/subscriptions/SubscriptionPriceType";
|
||||
import { DefaultFeatures } from "../dtos/shared/DefaultFeatures";
|
||||
import { SubscriptionPriceDto } from "../dtos/subscriptions/SubscriptionPriceDto";
|
||||
import { SubscriptionProductDto } from "../dtos/subscriptions/SubscriptionProductDto";
|
||||
import { SubscriptionUsageBasedPriceDto } from "../dtos/subscriptions/SubscriptionUsageBasedPriceDto";
|
||||
import { SubscriptionUsageBasedTierDto } from "../dtos/subscriptions/SubscriptionUsageBasedTierDto";
|
||||
import { PricingModel } from "../enums/subscriptions/PricingModel";
|
||||
import { SubscriptionFeatureLimitType } from "../enums/subscriptions/SubscriptionFeatureLimitType";
|
||||
|
||||
const UNIT_API_CALL = {
|
||||
name: "api",
|
||||
title: "API Call",
|
||||
titlePlural: "API Calls",
|
||||
};
|
||||
|
||||
function generatePrice(currency: string, price: number, billingPeriod: SubscriptionBillingPeriod): SubscriptionPriceDto {
|
||||
return {
|
||||
stripeId: "",
|
||||
subscriptionProductId: "",
|
||||
type: billingPeriod === SubscriptionBillingPeriod.ONCE ? SubscriptionPriceType.ONE_TIME : SubscriptionPriceType.RECURRING,
|
||||
billingPeriod,
|
||||
price: Math.round(price * 100) / 100,
|
||||
currency,
|
||||
trialDays: 0,
|
||||
active: true,
|
||||
usageBasedPrices: [],
|
||||
};
|
||||
}
|
||||
|
||||
function generateUsageBasedPrice(
|
||||
currency: string,
|
||||
unit: {
|
||||
name: string;
|
||||
title: string;
|
||||
titlePlural: string;
|
||||
},
|
||||
usageType: "licensed" | "metered",
|
||||
aggregateUsage: "last_during_period" | "last_ever" | "max" | "sum",
|
||||
tiersMode: "graduated" | "volume",
|
||||
billingScheme: "per_unit" | "tiered",
|
||||
tiers: {
|
||||
from: number;
|
||||
to: undefined | number;
|
||||
perUnitPrice: number | undefined;
|
||||
flatFeePrice: number | undefined;
|
||||
}[]
|
||||
): SubscriptionUsageBasedPriceDto {
|
||||
const usageBasedPriceTiers: SubscriptionUsageBasedTierDto[] = [];
|
||||
tiers.forEach((tier) => {
|
||||
usageBasedPriceTiers.push({
|
||||
id: "",
|
||||
subscriptionUsageBasedPriceId: "",
|
||||
...tier,
|
||||
});
|
||||
});
|
||||
return {
|
||||
id: "",
|
||||
stripeId: "",
|
||||
subscriptionProductId: "",
|
||||
billingPeriod: SubscriptionBillingPeriod.MONTHLY,
|
||||
currency,
|
||||
unit: unit.name,
|
||||
unitTitle: unit.title,
|
||||
unitTitlePlural: unit.titlePlural,
|
||||
usageType,
|
||||
aggregateUsage,
|
||||
tiersMode,
|
||||
billingScheme,
|
||||
tiers: usageBasedPriceTiers,
|
||||
};
|
||||
}
|
||||
|
||||
function generateCommonPlan(order: number, model: PricingModel) {
|
||||
if (order === 1) {
|
||||
return {
|
||||
stripeId: "",
|
||||
order,
|
||||
title: "pricing.products.plan1.title",
|
||||
description: "pricing.products.plan1.description",
|
||||
model,
|
||||
public: true,
|
||||
features: [
|
||||
{
|
||||
order: 1,
|
||||
title: "pricing.features.users.max",
|
||||
name: DefaultFeatures.Users,
|
||||
value: 2,
|
||||
type: SubscriptionFeatureLimitType.MAX,
|
||||
accumulate: false,
|
||||
},
|
||||
{
|
||||
order: 3,
|
||||
title: "pricing.features.apiCalls.units",
|
||||
name: DefaultFeatures.API,
|
||||
value: 0,
|
||||
type: SubscriptionFeatureLimitType.NOT_INCLUDED,
|
||||
accumulate: false,
|
||||
},
|
||||
{
|
||||
order: 4,
|
||||
title: "pricing.features.prioritySupport.none",
|
||||
name: DefaultFeatures.PrioritySupport,
|
||||
value: 0,
|
||||
type: SubscriptionFeatureLimitType.NOT_INCLUDED,
|
||||
accumulate: false,
|
||||
},
|
||||
],
|
||||
badge: "",
|
||||
active: true,
|
||||
prices: [],
|
||||
};
|
||||
} else if (order === 2) {
|
||||
return {
|
||||
stripeId: "",
|
||||
order,
|
||||
title: "pricing.products.plan2.title",
|
||||
description: "pricing.products.plan2.description",
|
||||
public: true,
|
||||
model,
|
||||
features: [
|
||||
{
|
||||
order: 1,
|
||||
title: "pricing.features.users.max",
|
||||
name: DefaultFeatures.Users,
|
||||
value: 5,
|
||||
type: SubscriptionFeatureLimitType.MAX,
|
||||
accumulate: false,
|
||||
},
|
||||
{
|
||||
order: 3,
|
||||
title: "pricing.features.apiCalls.monthly",
|
||||
name: DefaultFeatures.API,
|
||||
value: 100,
|
||||
type: SubscriptionFeatureLimitType.MONTHLY,
|
||||
accumulate: false,
|
||||
},
|
||||
{
|
||||
order: 4,
|
||||
title: "pricing.features.prioritySupport.basic",
|
||||
name: DefaultFeatures.PrioritySupport,
|
||||
value: 0,
|
||||
type: SubscriptionFeatureLimitType.INCLUDED,
|
||||
accumulate: false,
|
||||
},
|
||||
],
|
||||
badge: "pricing.recommended",
|
||||
active: true,
|
||||
};
|
||||
} else if (order === 3) {
|
||||
return {
|
||||
stripeId: "",
|
||||
order,
|
||||
title: "pricing.products.plan3.title",
|
||||
description: "pricing.products.plan3.description",
|
||||
public: true,
|
||||
model,
|
||||
features: [
|
||||
{
|
||||
order: 1,
|
||||
title: "pricing.features.users.max",
|
||||
name: DefaultFeatures.Users,
|
||||
value: 12,
|
||||
type: SubscriptionFeatureLimitType.MAX,
|
||||
accumulate: false,
|
||||
},
|
||||
{
|
||||
order: 3,
|
||||
title: "pricing.features.apiCalls.unlimited",
|
||||
name: DefaultFeatures.API,
|
||||
value: 0,
|
||||
type: SubscriptionFeatureLimitType.UNLIMITED,
|
||||
accumulate: false,
|
||||
},
|
||||
{
|
||||
order: 4,
|
||||
title: "pricing.features.prioritySupport.priority",
|
||||
name: DefaultFeatures.PrioritySupport,
|
||||
value: 0,
|
||||
type: SubscriptionFeatureLimitType.INCLUDED,
|
||||
accumulate: false,
|
||||
},
|
||||
],
|
||||
badge: "",
|
||||
active: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
stripeId: "",
|
||||
order,
|
||||
title: "pricing.products.plan1.title",
|
||||
description: "pricing.products.plan1.description",
|
||||
model,
|
||||
public: true,
|
||||
features: [
|
||||
{
|
||||
order: 1,
|
||||
title: "pricing.features.users.one",
|
||||
name: DefaultFeatures.Users,
|
||||
value: 1,
|
||||
type: SubscriptionFeatureLimitType.MAX,
|
||||
accumulate: false,
|
||||
},
|
||||
],
|
||||
badge: "",
|
||||
active: true,
|
||||
};
|
||||
}
|
||||
|
||||
const FLAT_RATE_PRICES: SubscriptionProductDto[] = [
|
||||
{
|
||||
...generateCommonPlan(1, PricingModel.FLAT_RATE),
|
||||
prices: [
|
||||
generatePrice("usd", 9, SubscriptionBillingPeriod.MONTHLY),
|
||||
generatePrice("usd", 90, SubscriptionBillingPeriod.YEARLY),
|
||||
generatePrice("mxn", 199, SubscriptionBillingPeriod.MONTHLY),
|
||||
generatePrice("mxn", 1990, SubscriptionBillingPeriod.YEARLY),
|
||||
],
|
||||
usageBasedPrices: [],
|
||||
},
|
||||
{
|
||||
...generateCommonPlan(2, PricingModel.FLAT_RATE),
|
||||
prices: [
|
||||
generatePrice("usd", 199, SubscriptionBillingPeriod.MONTHLY),
|
||||
generatePrice("usd", 1990, SubscriptionBillingPeriod.YEARLY),
|
||||
generatePrice("mxn", 3999, SubscriptionBillingPeriod.MONTHLY),
|
||||
generatePrice("mxn", 39990, SubscriptionBillingPeriod.YEARLY),
|
||||
],
|
||||
usageBasedPrices: [],
|
||||
},
|
||||
{
|
||||
...generateCommonPlan(3, PricingModel.FLAT_RATE),
|
||||
prices: [
|
||||
generatePrice("usd", 399, SubscriptionBillingPeriod.MONTHLY),
|
||||
generatePrice("usd", 3990, SubscriptionBillingPeriod.YEARLY),
|
||||
generatePrice("mxn", 7999, SubscriptionBillingPeriod.MONTHLY),
|
||||
generatePrice("mxn", 79990, SubscriptionBillingPeriod.YEARLY),
|
||||
],
|
||||
usageBasedPrices: [],
|
||||
},
|
||||
];
|
||||
|
||||
const PER_SEAT_PRICES: SubscriptionProductDto[] = [
|
||||
...FLAT_RATE_PRICES.map((item) => {
|
||||
return { ...item, model: PricingModel.PER_SEAT };
|
||||
}),
|
||||
];
|
||||
|
||||
const USAGE_BASED_PRICES: SubscriptionProductDto[] = [
|
||||
{
|
||||
...generateCommonPlan(1, PricingModel.USAGE_BASED),
|
||||
prices: [],
|
||||
usageBasedPrices: [
|
||||
generateUsageBasedPrice("usd", UNIT_API_CALL, "metered", "sum", "volume", "tiered", [
|
||||
{ from: 0, to: 10, perUnitPrice: 0.0, flatFeePrice: undefined },
|
||||
{ from: 11, to: 20, perUnitPrice: 0.02, flatFeePrice: 5 },
|
||||
{ from: 21, to: undefined, perUnitPrice: 0.01, flatFeePrice: 10 },
|
||||
]),
|
||||
generateUsageBasedPrice("mxn", UNIT_API_CALL, "metered", "sum", "volume", "tiered", [
|
||||
{ from: 0, to: 10, perUnitPrice: 0.0, flatFeePrice: undefined },
|
||||
{ from: 11, to: 20, perUnitPrice: 0.4, flatFeePrice: 100 },
|
||||
{ from: 21, to: undefined, perUnitPrice: 0.2, flatFeePrice: 200 },
|
||||
]),
|
||||
],
|
||||
},
|
||||
{
|
||||
...generateCommonPlan(2, PricingModel.USAGE_BASED),
|
||||
prices: [],
|
||||
usageBasedPrices: [
|
||||
generateUsageBasedPrice("usd", UNIT_API_CALL, "metered", "sum", "volume", "tiered", [
|
||||
{ from: 0, to: 10, perUnitPrice: 0.0, flatFeePrice: undefined },
|
||||
{ from: 11, to: 20, perUnitPrice: 0.04, flatFeePrice: 10 },
|
||||
{ from: 21, to: undefined, perUnitPrice: 0.02, flatFeePrice: 20 },
|
||||
]),
|
||||
generateUsageBasedPrice("mxn", UNIT_API_CALL, "metered", "sum", "volume", "tiered", [
|
||||
{ from: 0, to: 10, perUnitPrice: 0.0, flatFeePrice: undefined },
|
||||
{ from: 11, to: 20, perUnitPrice: 0.8, flatFeePrice: 200 },
|
||||
{ from: 21, to: undefined, perUnitPrice: 0.4, flatFeePrice: 400 },
|
||||
]),
|
||||
],
|
||||
},
|
||||
{
|
||||
...generateCommonPlan(3, PricingModel.USAGE_BASED),
|
||||
prices: [],
|
||||
usageBasedPrices: [
|
||||
generateUsageBasedPrice("usd", UNIT_API_CALL, "metered", "sum", "volume", "tiered", [
|
||||
{ from: 0, to: 10, perUnitPrice: 0.0, flatFeePrice: undefined },
|
||||
{ from: 11, to: 20, perUnitPrice: 0.06, flatFeePrice: 15 },
|
||||
{ from: 21, to: undefined, perUnitPrice: 0.03, flatFeePrice: 30 },
|
||||
]),
|
||||
generateUsageBasedPrice("mxn", UNIT_API_CALL, "metered", "sum", "volume", "tiered", [
|
||||
{ from: 0, to: 10, perUnitPrice: 0.0, flatFeePrice: undefined },
|
||||
{ from: 11, to: 20, perUnitPrice: 1.2, flatFeePrice: 300 },
|
||||
{ from: 21, to: undefined, perUnitPrice: 0.6, flatFeePrice: 600 },
|
||||
]),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const FLAT_RATE_PLUS_USAGE_BASED_PRICES: SubscriptionProductDto[] = [
|
||||
...FLAT_RATE_PRICES.map((flatRate) => {
|
||||
const usageBasedPrices = USAGE_BASED_PRICES.find((f) => f.order === flatRate.order)?.usageBasedPrices ?? [];
|
||||
return {
|
||||
...flatRate,
|
||||
usageBasedPrices,
|
||||
model: PricingModel.FLAT_RATE_USAGE_BASED,
|
||||
};
|
||||
}),
|
||||
];
|
||||
|
||||
const ONE_TIME_PRICES: SubscriptionProductDto[] = [
|
||||
{
|
||||
...generateCommonPlan(1, PricingModel.ONCE),
|
||||
prices: [generatePrice("usd", 99 * 2, SubscriptionBillingPeriod.ONCE), generatePrice("mxn", 1999 * 2, SubscriptionBillingPeriod.ONCE)],
|
||||
usageBasedPrices: [],
|
||||
},
|
||||
{
|
||||
...generateCommonPlan(2, PricingModel.ONCE),
|
||||
prices: [generatePrice("usd", 499 * 2, SubscriptionBillingPeriod.ONCE), generatePrice("mxn", 9999 * 2, SubscriptionBillingPeriod.ONCE)],
|
||||
usageBasedPrices: [],
|
||||
},
|
||||
{
|
||||
...generateCommonPlan(3, PricingModel.ONCE),
|
||||
prices: [generatePrice("usd", 1999 * 2, SubscriptionBillingPeriod.ONCE), generatePrice("mxn", 4999 * 2, SubscriptionBillingPeriod.ONCE)],
|
||||
usageBasedPrices: [],
|
||||
},
|
||||
];
|
||||
|
||||
const plans = [...FLAT_RATE_PRICES, ...PER_SEAT_PRICES, ...USAGE_BASED_PRICES, ...FLAT_RATE_PLUS_USAGE_BASED_PRICES, ...ONE_TIME_PRICES];
|
||||
export default plans;
|
||||
Reference in new issue
Block a user