When integrating Stripe Subscriptions in a .NET application using Entity Framework Core, one of the most common issues developers face is dealing with the checkout.session.completed webhook. If you have a relational database, you probably have a SubscriptionPlans table and a UserSubscriptions table. A frequent mistake is forgetting to map the Stripe Price ID back to your internal Database Plan ID when the webhook fires. If you just try to insert the subscription, EF Core will default your Foreign Key to 0, resulting in a nasty Foreign Key constraint violation (Error 500). Here is the clean way to handle the webhook and map the Stripe Price ID to your internal database ID: private async Task HandleCheckoutSessionCompleted ( Session session ) { var userId = session . ClientReferenceId ; // We passed this during checkout var subscriptionService = new SubscriptionService (); var stripeSubscription = await subscriptionService . GetAsync ( session . SubscriptionId ); // 1.…