MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / create

Function create

apps/web/pages/api/plans/index.ts:87–122  ·  view source on GitHub ↗
({
  email,
  communityId,
  priceId,
  successUrl,
  cancelUrl,
}: {
  email: string;
  communityId: string;
  priceId: string;
  successUrl: string;
  cancelUrl: string;
})

Source from the content-addressed store, hash-verified

85}
86
87export async function create({
88 email,
89 communityId,
90 priceId,
91 successUrl,
92 cancelUrl,
93}: {
94 email: string;
95 communityId: string;
96 priceId: string;
97 successUrl: string;
98 cancelUrl: string;
99}) {
100 const customer = await findOrCreateCustomer(communityId, email);
101
102 const session = await stripe.checkout.sessions.create({
103 mode: 'subscription',
104 line_items: [
105 {
106 price: priceId,
107 quantity: 1,
108 },
109 ],
110 subscription_data: {
111 trial_period_days: 14,
112 },
113 metadata: {
114 communityId,
115 email,
116 },
117 success_url: `${successUrl}?session_id={CHECKOUT_SESSION_ID}`,
118 cancel_url: cancelUrl,
119 customer: customer.id,
120 });
121 return session.url;
122}
123
124export default async function handler(
125 request: NextApiRequest,

Callers 1

handlerFunction · 0.70

Calls 2

findOrCreateCustomerFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected