Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: add plan to slack notification for new customer signup
Brad Barbinaf6a4b626fa4
diff --git a/packages/stripe/src/stripe.server.ts b/packages/stripe/src/stripe.server.tsindex 69168fb4dc..1ea6cc9a98 100644--- a/packages/stripe/src/stripe.server.ts+++ b/packages/stripe/src/stripe.server.ts@@ -325,7 +325,6 @@ export async function processStripeEvent({const eventType = event.type;if (eventType === "checkout.session.completed") {- const slackClient = getSlackClient();const data = event.data.object as Stripe.Checkout.Session;const { customer } = data;@@ -351,24 +350,11 @@ export async function processStripeEvent({companyId,userId,}),- slackClient.sendMessage({- channel: "#sales",- text: "New Customer 🔔",- blocks: [- {- type: "section",- text: {- type: "mrkdwn",- text:- `*New Signup* 🔔\n\n` +- `*Contact Information*\n` +- `• Company: ${data.customer_details?.name}\n\n` +- `• Email: ${data.customer_details?.email}\n\n` +- `• Plan: $${data.line_items?.data[0]?.description}\n\n`,- },- },- ],- }),+ sendNewCustomerNotification(+ customer,+ companyId,+ data.customer_details?.email+ ),]);} catch (error) {console.error("Error processing webhook:", error);@@ -414,6 +400,48 @@ export async function processStripeEvent({}}+async function sendNewCustomerNotification(+ customerId: string,+ companyId: string,+ email?: string+) {+ const slackClient = getSlackClient();+ const subscriptions = await stripe.subscriptions.list({+ customer: customerId,+ limit: 1,+ status: "all",+ expand: ["data.default_payment_method"],+ });++ const serviceRole = getCarbonServiceRole();++ const subscription = subscriptions.data[0];++ const [company, plan] = await Promise.all([+ serviceRole.from("company").select("*").eq("id", companyId).single(),+ getPlanByPriceId(serviceRole, subscription.items.data[0].price.id),+ ]);++ slackClient.sendMessage({+ channel: "#sales",+ text: "New Customer 🔔",+ blocks: [+ {+ type: "section",+ text: {+ type: "mrkdwn",+ text:+ `*New Signup* 🔔\n\n` ++ `*Contact Information*\n` ++ `• Company: ${company.data?.name}\n\n` ++ `• Email: ${email ?? company.data?.email}\n\n` ++ `• Plan: $${plan.data?.name}\n\n`,+ },+ },+ ],+ });+}+export async function syncStripeDataToKV(customerId: string,companyIdFromMetadata?: string