diff --git a/apps/web/config/billing.config.ts b/apps/web/config/billing.config.ts index c3009ca5c..10d35be9f 100644 --- a/apps/web/config/billing.config.ts +++ b/apps/web/config/billing.config.ts @@ -25,7 +25,7 @@ export default createBillingSchema({ paymentType: 'one-time', lineItems: [ { - id: 'price_1P0jgcI1i3VnbZTqXVXaZkMP', + id: '324643', name: 'Base', description: 'Base plan', cost: 999.99, diff --git a/packages/billing/lemon-squeezy/src/services/lemon-squeezy-webhook-handler.service.ts b/packages/billing/lemon-squeezy/src/services/lemon-squeezy-webhook-handler.service.ts index fd3b0e3e4..7f5f94548 100644 --- a/packages/billing/lemon-squeezy/src/services/lemon-squeezy-webhook-handler.service.ts +++ b/packages/billing/lemon-squeezy/src/services/lemon-squeezy-webhook-handler.service.ts @@ -1,4 +1,4 @@ -import { getOrder } from '@lemonsqueezy/lemonsqueezy.js'; +import { getOrder, getVariant } from '@lemonsqueezy/lemonsqueezy.js'; import { createHmac, timingSafeEqual } from 'crypto'; import { BillingWebhookHandlerService } from '@kit/billing'; @@ -139,10 +139,15 @@ export class LemonSqueezyWebhookHandlerService ) { await initializeLemonSqueezyClient(); - const subscription = event.data.relationships.subscriptions.links.self; + // we fetch the variant to check if the order is a subscription + // if Lemon Squeezy was able to discriminate between orders and subscriptions + // it would be better to use that information. But for now, we need to fetch the variant + const variantId = event.data.attributes.first_order_item.variant_id; + const { data } = await getVariant(variantId); - if (subscription) { - // we handle the subscription created event instead + // if the order is a subscription + // we handle it in the subscription created event + if (data?.data.attributes.is_subscription) { return; } diff --git a/supabase/migrations/20221215192558_schema.sql b/supabase/migrations/20221215192558_schema.sql index cdfc96d93..140278c37 100644 --- a/supabase/migrations/20221215192558_schema.sql +++ b/supabase/migrations/20221215192558_schema.sql @@ -1676,7 +1676,7 @@ create policy create_org_account on public.accounts for insert to authenticated with check ( public.is_set( - 'enable_organization_accounts') + 'enable_team_accounts') and public.accounts.is_personal_account = false); create or replace function public.create_invitation(account_id uuid,