1. Updated packages
2. Added comments to schema 3. Minor API updates
This commit is contained in:
@@ -4,11 +4,11 @@ import {
|
||||
CancelSubscriptionParamsSchema,
|
||||
CreateBillingCheckoutSchema,
|
||||
CreateBillingPortalSessionSchema,
|
||||
QueryBillingUsageSchema,
|
||||
ReportBillingUsageSchema,
|
||||
RetrieveCheckoutSessionSchema,
|
||||
UpdateSubscriptionParamsSchema,
|
||||
} from '../schema';
|
||||
import { QueryBillingUsageSchema } from '../schema/query-billing-usage.schema';
|
||||
|
||||
export abstract class BillingStrategyProviderService {
|
||||
abstract createBillingPortalSession(
|
||||
@@ -53,7 +53,7 @@ export abstract class BillingStrategyProviderService {
|
||||
value: number;
|
||||
}>;
|
||||
|
||||
abstract updateSubscription(
|
||||
abstract updateSubscriptionItem(
|
||||
params: z.infer<typeof UpdateSubscriptionParamsSchema>,
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@kit/ui": "workspace:^",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@types/react": "^18.2.79",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"@types/react": "^18.3.1",
|
||||
"date-fns": "^3.6.0",
|
||||
"lucide-react": "^0.373.0",
|
||||
"lucide-react": "^0.376.0",
|
||||
"next": "14.2.3",
|
||||
"react": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"react-hook-form": "^7.51.3",
|
||||
"react-i18next": "^14.1.1",
|
||||
"zod": "^3.23.4"
|
||||
|
||||
@@ -44,10 +44,7 @@ class BillingGatewayService {
|
||||
async createCheckoutSession(
|
||||
params: z.infer<typeof CreateBillingCheckoutSchema>,
|
||||
) {
|
||||
const strategy = await BillingGatewayFactoryService.GetProviderStrategy(
|
||||
this.provider,
|
||||
);
|
||||
|
||||
const strategy = await this.getStrategy();
|
||||
const payload = CreateBillingCheckoutSchema.parse(params);
|
||||
|
||||
return strategy.createCheckoutSession(payload);
|
||||
@@ -61,10 +58,7 @@ class BillingGatewayService {
|
||||
async retrieveCheckoutSession(
|
||||
params: z.infer<typeof RetrieveCheckoutSessionSchema>,
|
||||
) {
|
||||
const strategy = await BillingGatewayFactoryService.GetProviderStrategy(
|
||||
this.provider,
|
||||
);
|
||||
|
||||
const strategy = await this.getStrategy();
|
||||
const payload = RetrieveCheckoutSessionSchema.parse(params);
|
||||
|
||||
return strategy.retrieveCheckoutSession(payload);
|
||||
@@ -78,10 +72,7 @@ class BillingGatewayService {
|
||||
async createBillingPortalSession(
|
||||
params: z.infer<typeof CreateBillingPortalSessionSchema>,
|
||||
) {
|
||||
const strategy = await BillingGatewayFactoryService.GetProviderStrategy(
|
||||
this.provider,
|
||||
);
|
||||
|
||||
const strategy = await this.getStrategy();
|
||||
const payload = CreateBillingPortalSessionSchema.parse(params);
|
||||
|
||||
return strategy.createBillingPortalSession(payload);
|
||||
@@ -95,10 +86,7 @@ class BillingGatewayService {
|
||||
async cancelSubscription(
|
||||
params: z.infer<typeof CancelSubscriptionParamsSchema>,
|
||||
) {
|
||||
const strategy = await BillingGatewayFactoryService.GetProviderStrategy(
|
||||
this.provider,
|
||||
);
|
||||
|
||||
const strategy = await this.getStrategy();
|
||||
const payload = CancelSubscriptionParamsSchema.parse(params);
|
||||
|
||||
return strategy.cancelSubscription(payload);
|
||||
@@ -110,10 +98,7 @@ class BillingGatewayService {
|
||||
* @param params
|
||||
*/
|
||||
async reportUsage(params: z.infer<typeof ReportBillingUsageSchema>) {
|
||||
const strategy = await BillingGatewayFactoryService.GetProviderStrategy(
|
||||
this.provider,
|
||||
);
|
||||
|
||||
const strategy = await this.getStrategy();
|
||||
const payload = ReportBillingUsageSchema.parse(params);
|
||||
|
||||
return strategy.reportUsage(payload);
|
||||
@@ -125,10 +110,7 @@ class BillingGatewayService {
|
||||
* @param params
|
||||
*/
|
||||
async queryUsage(params: z.infer<typeof QueryBillingUsageSchema>) {
|
||||
const strategy = await BillingGatewayFactoryService.GetProviderStrategy(
|
||||
this.provider,
|
||||
);
|
||||
|
||||
const strategy = await this.getStrategy();
|
||||
const payload = QueryBillingUsageSchema.parse(params);
|
||||
|
||||
return strategy.queryUsage(payload);
|
||||
@@ -141,12 +123,13 @@ class BillingGatewayService {
|
||||
async updateSubscriptionItem(
|
||||
params: z.infer<typeof UpdateSubscriptionParamsSchema>,
|
||||
) {
|
||||
const strategy = await BillingGatewayFactoryService.GetProviderStrategy(
|
||||
this.provider,
|
||||
);
|
||||
|
||||
const strategy = await this.getStrategy();
|
||||
const payload = UpdateSubscriptionParamsSchema.parse(params);
|
||||
|
||||
return strategy.updateSubscription(payload);
|
||||
return strategy.updateSubscriptionItem(payload);
|
||||
}
|
||||
|
||||
getStrategy() {
|
||||
return BillingGatewayFactoryService.GetProviderStrategy(this.provider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@kit/ui": "workspace:^",
|
||||
"@types/react": "^18.2.79",
|
||||
"@types/react": "^18.3.1",
|
||||
"next": "14.2.3",
|
||||
"react": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"zod": "^3.23.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -307,7 +307,7 @@ export class LemonSqueezyBillingStrategyService
|
||||
* @description Queries the usage of the metered billing
|
||||
* @param params
|
||||
*/
|
||||
async updateSubscription(
|
||||
async updateSubscriptionItem(
|
||||
params: z.infer<typeof UpdateSubscriptionParamsSchema>,
|
||||
) {
|
||||
const logger = await getLogger();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"dependencies": {
|
||||
"@stripe/react-stripe-js": "^2.7.0",
|
||||
"@stripe/stripe-js": "^3.3.0",
|
||||
"stripe": "^15.3.0"
|
||||
"stripe": "^15.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/billing": "workspace:^",
|
||||
@@ -28,10 +28,10 @@
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@kit/ui": "workspace:^",
|
||||
"@types/react": "^18.2.79",
|
||||
"@types/react": "^18.3.1",
|
||||
"date-fns": "^3.6.0",
|
||||
"next": "14.2.3",
|
||||
"react": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"zod": "^3.23.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -273,11 +273,11 @@ export class StripeBillingStrategyService
|
||||
}
|
||||
|
||||
/**
|
||||
* @name updateSubscription
|
||||
* @name updateSubscriptionItem
|
||||
* @description Updates a subscription
|
||||
* @param params
|
||||
*/
|
||||
async updateSubscription(
|
||||
async updateSubscriptionItem(
|
||||
params: z.infer<typeof UpdateSubscriptionParamsSchema>,
|
||||
) {
|
||||
const stripe = await this.stripeProvider();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"./route-handler": "./src/keystatic-route-handler.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@keystatic/core": "0.5.12",
|
||||
"@keystatic/core": "0.5.13",
|
||||
"@keystatic/next": "5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/team-accounts": "workspace:^",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"zod": "^3.23.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -32,15 +32,15 @@
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@kit/ui": "workspace:^",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"@tanstack/react-query": "5.32.0",
|
||||
"@types/react": "^18.2.79",
|
||||
"@types/react-dom": "^18.2.25",
|
||||
"lucide-react": "^0.373.0",
|
||||
"@types/react": "^18.3.1",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"lucide-react": "^0.376.0",
|
||||
"next": "14.2.3",
|
||||
"next-themes": "0.3.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-hook-form": "^7.51.3",
|
||||
"react-i18next": "^14.1.1",
|
||||
"sonner": "^1.4.41",
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
"@kit/ui": "workspace:^",
|
||||
"@makerkit/data-loader-supabase-core": "^0.0.7",
|
||||
"@makerkit/data-loader-supabase-nextjs": "^1.1.0",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"@tanstack/react-query": "5.32.0",
|
||||
"@tanstack/react-table": "^8.16.0",
|
||||
"@types/react": "^18.2.79",
|
||||
"lucide-react": "^0.373.0",
|
||||
"@types/react": "^18.3.1",
|
||||
"lucide-react": "^0.376.0",
|
||||
"next": "14.2.3",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-hook-form": "^7.51.3",
|
||||
"zod": "^3.23.4"
|
||||
},
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@kit/ui": "workspace:^",
|
||||
"@marsidev/react-turnstile": "^0.5.4",
|
||||
"@marsidev/react-turnstile": "^0.6.0",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"@tanstack/react-query": "5.32.0",
|
||||
"@types/react": "^18.2.79",
|
||||
"lucide-react": "^0.373.0",
|
||||
"@types/react": "^18.3.1",
|
||||
"lucide-react": "^0.376.0",
|
||||
"next": "14.2.3",
|
||||
"react-hook-form": "^7.51.3",
|
||||
"react-i18next": "^14.1.1",
|
||||
|
||||
@@ -30,17 +30,17 @@
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@kit/ui": "workspace:^",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"@tanstack/react-query": "5.32.0",
|
||||
"@tanstack/react-table": "^8.16.0",
|
||||
"@types/react": "^18.2.79",
|
||||
"@types/react-dom": "^18.2.25",
|
||||
"@types/react": "^18.3.1",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"date-fns": "^3.6.0",
|
||||
"lucide-react": "^0.373.0",
|
||||
"lucide-react": "^0.376.0",
|
||||
"next": "14.2.3",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-hook-form": "^7.51.3",
|
||||
"react-i18next": "^14.1.1",
|
||||
"sonner": "^1.4.41",
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
"@kit/sentry": "workspace:*",
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@types/react": "^18.2.79",
|
||||
"react": "18.2.0"
|
||||
"@types/react": "^18.3.1",
|
||||
"react": "18.3.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
"@kit/prettier-config": "workspace:*",
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@types/react": "^18.2.79",
|
||||
"react": "18.2.0",
|
||||
"@types/react": "^18.3.1",
|
||||
"react": "18.3.1",
|
||||
"zod": "^3.23.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
"@kit/prettier-config": "workspace:*",
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@types/react": "^18.2.79",
|
||||
"react": "18.2.0"
|
||||
"@types/react": "^18.3.1",
|
||||
"react": "18.3.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
"@kit/prettier-config": "workspace:*",
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@types/react": "^18.2.79",
|
||||
"react": "18.2.0"
|
||||
"@types/react": "^18.3.1",
|
||||
"react": "18.3.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"@kit/supabase": "workspace:^",
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"next": "14.2.3",
|
||||
"zod": "^3.23.4"
|
||||
},
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@supabase/gotrue-js": "2.62.2",
|
||||
"@supabase/ssr": "^0.3.0",
|
||||
"@supabase/supabase-js": "^2.42.6",
|
||||
"@supabase/supabase-js": "^2.42.7",
|
||||
"@tanstack/react-query": "5.32.0",
|
||||
"@types/react": "^18.2.79",
|
||||
"@types/react": "^18.3.1",
|
||||
"next": "14.2.3",
|
||||
"react": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"zod": "^3.23.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "1.0.0",
|
||||
"input-otp": "1.2.4",
|
||||
"lucide-react": "^0.373.0",
|
||||
"lucide-react": "^0.376.0",
|
||||
"react-top-loading-bar": "2.3.1",
|
||||
"tailwind-merge": "^2.3.0"
|
||||
},
|
||||
@@ -41,8 +41,8 @@
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@tanstack/react-table": "^8.16.0",
|
||||
"@types/react": "^18.2.79",
|
||||
"@types/react-dom": "^18.2.25",
|
||||
"@types/react": "^18.3.1",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"date-fns": "^3.6.0",
|
||||
"eslint": "^8.57.0",
|
||||
|
||||
Reference in New Issue
Block a user