File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ const handler = async (data: SWHMap["checkout.session.completed"]["data"]) => {
4545 return await handleCalAIPhoneNumberSubscription ( session ) ;
4646 }
4747
48+ if ( session . metadata ?. type === CHECKOUT_SESSION_TYPES . TEAM_CREATION ) {
49+ return await handleTeamCreationCheckoutSessionComplete ( session ) ;
50+ }
51+
4852 // Handle credit purchases (existing logic)
4953 if ( ! session . amount_total ) {
5054 throw new HttpCode ( 400 , "Missing required payment details" ) ;
@@ -105,6 +109,17 @@ async function saveToCreditBalance({
105109 }
106110}
107111
112+ async function handleTeamCreationCheckoutSessionComplete (
113+ session : SWHMap [ "checkout.session.completed" ] [ "data" ] [ "object" ]
114+ ) {
115+ log . info ( "Team creation checkout session completed - handled via redirect flow" , {
116+ sessionId : session . id ,
117+ teamName : session . metadata ?. teamName ,
118+ teamSlug : session . metadata ?. teamSlug ,
119+ } ) ;
120+ return { success : true , message : "Team checkout handled via redirect" } ;
121+ }
122+
108123async function handleCalAIPhoneNumberSubscription (
109124 session : SWHMap [ "checkout.session.completed" ] [ "data" ] [ "object" ]
110125) {
Original file line number Diff line number Diff line change 44 */
55export const CHECKOUT_SESSION_TYPES = {
66 PHONE_NUMBER_SUBSCRIPTION : "phone_number_subscription" ,
7+ TEAM_CREATION : "team_creation" ,
78} as const ;
89
910export type CheckoutSessionType = ( typeof CHECKOUT_SESSION_TYPES ) [ keyof typeof CHECKOUT_SESSION_TYPES ] ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { z } from "zod";
44import { getStripeCustomerIdFromUserId } from "@calcom/app-store/stripepayment/lib/customer" ;
55import { getDubCustomer } from "@calcom/features/auth/lib/dub" ;
66import stripe from "@calcom/features/ee/payments/server/stripe" ;
7+ import { CHECKOUT_SESSION_TYPES } from "@calcom/features/ee/billing/constants" ;
78import {
89 IS_PRODUCTION ,
910 ORGANIZATION_SELF_SERVE_PRICE ,
@@ -98,6 +99,7 @@ export const generateTeamCheckoutSession = async ({
9899 trial_period_days : 14 , // Add a 14-day trial
99100 } ,
100101 metadata : {
102+ type : CHECKOUT_SESSION_TYPES . TEAM_CREATION ,
101103 teamName,
102104 teamSlug,
103105 userId,
You can’t perform that action at this time.
0 commit comments