feat: open billing for lmz customers #538
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import { env } from '$env/dynamic/private';
|
||||
import { lemonSqueezySetup } from '@lemonsqueezy/lemonsqueezy.js';
|
||||
|
||||
export function configureLemonSqueezy() {
|
||||
return lemonSqueezySetup({
|
||||
apiKey: env.LEMON_SQUEEZY_API_KEY,
|
||||
onError: (error) => {
|
||||
throw new Error(`Lemon Squeezy API error: ${error.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { getAccessToken } from '$lib/utils/functions/supabase';
|
||||
import axios from 'axios';
|
||||
|
||||
interface SubscriptionData {
|
||||
productId: string;
|
||||
email: string;
|
||||
name: string;
|
||||
triggeredBy: string;
|
||||
orgId: string;
|
||||
}
|
||||
|
||||
interface SubscriptionResponse {
|
||||
success: boolean;
|
||||
checkoutURL: string;
|
||||
}
|
||||
|
||||
export async function subscribeToProduct(data: SubscriptionData): Promise<SubscriptionResponse> {
|
||||
const accessToken = await getAccessToken();
|
||||
|
||||
const response = await axios({
|
||||
method: 'POST',
|
||||
url: '/api/lmz/subscribe',
|
||||
data,
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`
|
||||
}
|
||||
});
|
||||
|
||||
return response.data;
|
||||
}
|
||||
@@ -77,6 +77,8 @@ export async function getOrganizations(userId: string, isOrgSite?: boolean, orgS
|
||||
organization_plan(
|
||||
plan_name,
|
||||
is_active,
|
||||
provider,
|
||||
subscriptionId:payload->id,
|
||||
customerId:payload->customerId
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user