B2B-88: add starter kit structure and elements
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { getCustomer } from '@lemonsqueezy/lemonsqueezy.js';
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { CreateBillingPortalSessionSchema } from '@kit/billing/schema';
|
||||
|
||||
import { initializeLemonSqueezyClient } from './lemon-squeezy-sdk';
|
||||
|
||||
/**
|
||||
* Creates a LemonSqueezy billing portal session for the given parameters.
|
||||
*
|
||||
* @param {object} params - The parameters required to create the billing portal session.
|
||||
*/
|
||||
export async function createLemonSqueezyBillingPortalSession(
|
||||
params: z.infer<typeof CreateBillingPortalSessionSchema>,
|
||||
) {
|
||||
await initializeLemonSqueezyClient();
|
||||
|
||||
const { data, error } = await getCustomer(params.customerId);
|
||||
|
||||
return {
|
||||
data: data?.data.attributes.urls.customer_portal,
|
||||
error,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user