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

Function findOrCreateCustomer

apps/web/pages/api/plans/index.ts:69–85  ·  view source on GitHub ↗
(communityId: string, email: string)

Source from the content-addressed store, hash-verified

67}
68
69async function findOrCreateCustomer(communityId: string, email: string) {
70 const { data } = await stripe.customers.search({
71 query: `metadata["communityId"]:"${communityId}"`,
72 });
73
74 return (
75 data[0] ||
76 (await stripe.customers.create({
77 name: `CUSTOMER ${communityId}`,
78 email,
79 metadata: {
80 email,
81 communityId,
82 },
83 }))
84 );
85}
86
87export async function create({
88 email,

Callers 1

createFunction · 0.85

Calls 1

createMethod · 0.45

Tested by

no test coverage detected