1. Updated packages

2. Added comments to schema
3. Minor API updates
This commit is contained in:
giancarlo
2024-04-27 14:39:28 +07:00
parent 259e6ba555
commit 07deb28e12
26 changed files with 2138 additions and 2243 deletions

View File

@@ -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"

View File

@@ -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);
}
}