feat: initial commit — storefront, convex backend, and shared packages
Completes the first milestone of The Pet Loft ecommerce platform: - apps/storefront: full customer-facing Next.js app with HeroUI (cart, checkout, orders, wishlist, product detail, shop, search, auth) - convex/: serverless backend with schema, queries, mutations, actions, HTTP routes, Stripe/Shippo integrations, and co-located tests - packages/types, packages/utils, packages/convex: shared workspace packages Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
24
convex/model/stripe.ts
Normal file
24
convex/model/stripe.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
"use node";
|
||||
|
||||
import Stripe from "stripe";
|
||||
|
||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
|
||||
|
||||
export async function getOrCreateStripeCustomer(input: {
|
||||
stripeCustomerId: string | undefined;
|
||||
email: string;
|
||||
name: string;
|
||||
convexUserId: string;
|
||||
}): Promise<string> {
|
||||
if (input.stripeCustomerId) {
|
||||
return input.stripeCustomerId;
|
||||
}
|
||||
|
||||
const customer = await stripe.customers.create({
|
||||
email: input.email,
|
||||
name: input.name,
|
||||
metadata: { convexUserId: input.convexUserId },
|
||||
});
|
||||
|
||||
return customer.id;
|
||||
}
|
||||
Reference in New Issue
Block a user