Update Stripe SDK to v18 and dependencies (#236)

* Update Stripe SDK and dependencies

1. Upgrade `stripe` package from version 17.7.0 to 18.0.0 in `package.json`.
2. Update `STRIPE_API_VERSION` in `stripe-sdk.ts` to '2025-03-31.basil'.
3. Refactor `StripeWebhookHandlerService` to retrieve subscription details using Supabase client, ensuring compatibility with the new Stripe version.
4. Introduce helper methods `getPeriodStartsAt` and `getPeriodEndsAt` for better handling of subscription periods based on the Stripe API changes.

These changes enhance the integration with the latest Stripe API and improve the overall reliability of the billing service.

* Refactor billing payload builders to remove config dependency

Removed direct dependency on `BillingConfig` in subscription payload builders.

Introduced `PlanTypeMap` to streamline plan type resolutions. Updated webhook handlers and event processing functions to handle plan types more efficiently and improve extensibility.

* Refactor Stripe subscription handling for improved accuracy
This commit is contained in:
Giancarlo Buomprisco
2025-04-22 09:42:12 +07:00
committed by GitHub
parent 4f41304be4
commit 903ef6dc08
13 changed files with 372 additions and 139 deletions

View File

@@ -1,3 +1,4 @@
import { getPlanTypesMap } from '@kit/billing';
import { getBillingEventHandlerService } from '@kit/billing-gateway';
import { enhanceRouteHandler } from '@kit/next/routes';
import { getLogger } from '@kit/shared/logger';
@@ -25,7 +26,7 @@ export const POST = enhanceRouteHandler(
const service = await getBillingEventHandlerService(
supabaseClientProvider,
provider,
billingConfig,
getPlanTypesMap(billingConfig),
);
try {