Update billing provider and related adjustments

This commit switches the billing provider from Stripe to Lemon Squeezy. It also includes necessary modifications in the web app, billing gateway, and database to accommodate this change. Additionally, updates have been made to the checkout process, billing strategy, and relevant services and components.
This commit is contained in:
giancarlo
2024-04-02 14:31:53 +08:00
parent 4576c8c14a
commit eb43059fda
3 changed files with 11 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ export default createBillingSchema({
paymentType: 'one-time',
lineItems: [
{
id: 'price_1P0jgcI1i3VnbZTqXVXaZkMP',
id: '324643',
name: 'Base',
description: 'Base plan',
cost: 999.99,

View File

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

View File

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