Best approach to integrate Calendly payments with Stripe for database storage?

I want to build a Next.js application that tracks paid appointments for users. The goal is to show customers a dashboard where they can see all their Calendly bookings that were processed through Stripe payments.

My plan is to create user accounts where people can log in and view their payment history in a nice table layout. I’m wondering what’s the most effective way to sync data between these two services and store everything in my database.

I understand both platforms offer APIs to fetch information, but I’m not sure about the best strategy to link the payment records from Stripe with the booking data from Calendly. How should I match these records using the user’s email address and unique identifier to maintain accurate records in my database?

Built something like this for subscription payments - webhooks are your best bet here.

Set up webhooks from Calendly and Stripe hitting different endpoints in your Next.js app. Match the events using email + timestamp when someone books and pays.

For the database, store both the Calendly event ID and Stripe payment intent ID in the same record. Creates a solid link between booking and payment.

Webhook retries caught me off guard. Both services retry failed webhooks, so make your endpoints idempotent. I just check if the event already exists before processing.

Email works for user matching, but add a custom field to Calendly bookings with your system’s user ID. Makes linking bulletproof.

Trickiest part? Failed payments and cancelled bookings. Build your sync logic to handle these edge cases from day one.

Did a similar integration last year - the trick is nailing your data relationships upfront. Don’t just match emails. Store a correlation ID that passes through both systems instead. Here’s what works: when someone books through Calendly, generate a unique reference in your database first. Send this reference as metadata to Calendly (URI parameters) and Stripe (payment metadata). Now you’ve got a three-way link with zero confusion. For the database, keep separate tables for bookings and payments, plus a junction table mapping their relationships. This saves you when payments get refunded or bookings get moved without losing history. Biggest headache I hit? Timezones. Calendly and Stripe timestamp events differently, so convert everything to UTC in your database right away. Also run a daily reconciliation job to catch missed webhook events - network hiccups are way more common than you think.

yeah, webhooks are super handy! they’ll let u get real-time updates instead of waiting on API calls. connecting em with user emails is smart too, makes it easy to keep track of everything. good luck setting it all up!