engineeringcal.comstripemarketplacesapi
Integrating Cal.com and Stripe for Mentorship Marketplaces
Engineering teams can use Discuno as a reference architecture for orchestrating Cal.com scheduling and Stripe Connect payouts in a mentorship marketplace.
4 min read
By Discuno Team
Mentorship marketplaces require flawless coordination between scheduling and payments. Cal.com creates deep availability controls, while Stripe Connect manages payouts and compliance. Discuno stitches both systems together with opinionated defaults that you can adapt to your own stack. This guide explains the reference architecture and shares implementation tips.
Architecture Overview
Mentee ➜ Discuno (Next.js 15) ➜ Cal.com API ➜ Booking Webhooks
│
└➜ Stripe Checkout ➜ Stripe Connect Payouts
- Frontend: Discuno’s Next.js 15 app renders dynamic scheduling flows with React Server Components and Tailwind CSS.
- Backend: Drizzle ORM (PostgreSQL) stores bookings, mentors, and payout states with audit logs.
- Integrations: Cal.com handles availability. Stripe Connect powers payments. PostHog logs analytics across both flows.
Cal.com Integration Pattern
- Managed users: Discuno provisions mentors as managed users within a Cal.com organization, ensuring availability policies are centrally enforced.
- Event types: Each mentorship format (intro session, project review, career roadmap) maps to a Cal.com event type with custom forms and location rules.
- Webhooks: Cal.com webhooks hit
apps/web/src/app/api/webhooks/cal/to persist bookings, attendees, and cancellations. Discuno’s handlers enforce idempotency and emit analytics events. - Token refresh: OAuth tokens live in the
discuno_calcom_tokentable with automatic refresh jobs to avoid unexpected 401 errors.
Sample Booking Flow
const session = await bookCalComEvent({
eventTypeSlug: 'mentor-career-roadmap',
mentee: { name, email },
answers: prepFormResponses,
})
await db.insert(discuno_booking).values({
calcomBookingId: session.id,
mentorId,
menteeId,
status: 'confirmed',
price: session.metadata.price,
})
Stripe Connect Integration Pattern
- Product catalog: Discuno maps Cal.com event types to Stripe prices so every session has a predictable SKU and revenue split.
- Checkout session: The mentee is routed through Stripe Checkout using signed URLs generated server-side with Zod validation.
- Holding funds: After payment succeeds, funds sit in a pending state while the mentorship session completes and the dispute window closes.
- Automated transfers: Cron jobs trigger after the hold period to transfer mentor earnings and platform fees via Stripe Connect’s
transferAPI. - Refunds: Cancellations within policy automatically trigger partial or full refunds, sync back to the booking record, and notify both participants.
Sample Payout Flow
await stripe.transfers.create({
amount: mentorPayoutInCents,
currency: 'usd',
destination: mentor.stripeAccountId,
metadata: {
bookingId,
mentorId,
program: programSlug,
},
})
Security and Compliance Considerations
- Least privilege: Discuno stores signed webhooks in encrypted columns and scopes API keys to specific environments (local, preview, production).
- Audit trails: Every booking change runs through Drizzle migrations with soft deletes and timestamp columns for compliance reporting.
- Tax reporting: Stripe Connect handles 1099 tax form generation. Discuno syncs status to mentor dashboards for transparency.
- Privacy: Better-auth ensures OAuth flows stay within your organization’s identity requirements, including SSO and domain restrictions.
Monitoring and Observability
- PostHog dashboards track conversion rates from session selection to completed payment.
- Sentry alerts flag integration errors, webhook failures, or API rate-limit issues to engineering teams.
- Cron job logs help support teams trace payout triggers and identify blocked mentors.
Implementation Checklist
- Configure Cal.com webhooks with secret verification
- Store Stripe secrets in environment variables validated by
apps/web/src/env.js - Seed mentors with Stripe onboarding URLs before launch
- Enable dispute monitoring and cancellation policies
- Add PostHog event tracking for
checkout_startedandsession_completed
When to Use Discuno as Your Baseline
- You need mentor availability rules more complex than “pick a time.”
- You want automated payments without building your own payout ledger.
- You must deliver compliance-ready audit logs to universities, enterprises, or accelerators.
- You prefer a TypeScript-first stack (Next.js, Drizzle ORM, Zod, Vitest) that your team can extend.
Want to skip months of integration work? Schedule a strategy call and use Discuno’s marketplace-first primitives as your launchpad.