2023-08-24 13:32:57 +10:00
|
|
|
'use server';
|
|
|
|
|
|
2023-08-30 16:36:22 +10:00
|
|
|
import { stripe } from '@documenso/lib/server-only/stripe';
|
2023-08-24 13:32:57 +10:00
|
|
|
|
|
|
|
|
export type GetPortalSessionOptions = {
|
|
|
|
|
customerId: string;
|
|
|
|
|
returnUrl: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getPortalSession = async ({ customerId, returnUrl }: GetPortalSessionOptions) => {
|
|
|
|
|
'use server';
|
|
|
|
|
|
|
|
|
|
const session = await stripe.billingPortal.sessions.create({
|
|
|
|
|
customer: customerId,
|
|
|
|
|
return_url: returnUrl,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return session.url;
|
|
|
|
|
};
|