MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / index

Function index

apps/web/pages/api/subscriptions/index.ts:34–53  ·  view source on GitHub ↗
({ communityId }: { communityId: string })

Source from the content-addressed store, hash-verified

32}
33
34export async function index({ communityId }: { communityId: string }) {
35 const response1 = await stripe.customers.search({
36 query: `metadata["communityId"]:"${communityId}"`,
37 });
38 const customer = response1.data[0];
39 const response2 = await stripe.subscriptions.list({
40 customer: customer.id,
41 });
42 const subscription = response2.data[0];
43 const paymentMethodId = subscription.default_payment_method as string;
44 const paymentMethod = await stripe.paymentMethods.retrieve(paymentMethodId);
45 return {
46 status: 200,
47 data: {
48 customer: serializeCustomer(customer),
49 subscription: serializeSubscription(subscription),
50 paymentMethod: serializePaymentMethod(paymentMethod),
51 },
52 };
53}
54
55export default async function handler(
56 request: NextApiRequest,

Callers 1

handlerFunction · 0.70

Calls 4

serializeCustomerFunction · 0.85
serializeSubscriptionFunction · 0.85
serializePaymentMethodFunction · 0.85
listMethod · 0.80

Tested by

no test coverage detected