Stripe Monthly Subscription Functionality

I could use some help troubleshooting a Stripe integration issue on my Replit project. I’ve overspent credits already, going in circles with the Agent. I’ve tried emailing support, but no help there either.

When a user makes a successful subscription payment through Stripe (in Test Mode), they’re redirected to the free account dashboard instead of the premium access dashboard.

• Stripe checkout + webhook are integrated.

• Webhook events are showing success in the logs (no failures).

• The Agent/assistant keeps saying it’s fixed, but the issue persists.

• I’ve tried refreshing, structured prompts with the help of ChatGPT, screenshots, verifying keys, using a real domain deployed url, etc. but still no luck.

Has anyone run into this before? Is there something specific in the webhook logic, user session handling, or Replit environment that could cause Stripe to process the payment successfully but still load the free account dashboard afterward? I feel that I’m almost about give up on Replit too.

Any guidance or example code fixes would be greatly appreciated :folded_hands: Thank you!

1 Like

You have webooks setup to proper dev env url?

The webhook shows all successes so far! And the url endpoint and keys look correct too.

And you configured the subscriptions/prices in Stripe’s backend first, yeah?

I ask because I don’t think you can rely on Stripe webhooks alone unless you’ve set up your subscription products and pricing in Stripe first. Stripe subscriptions are stateful and managed on Stripe’s servers, so your app needs to work with the subscription object that Stripe creates. If you haven’t configured the products and pricing, Stripe will still send the “success” webhook you’re getting when checkout completes, but there will be no subscription data for your app to reference, which may be why users are being sent to the free dashboard.

Make sure you have an actual subscription product and recurring price configured in Stripe, and confirm that your checkout session is using mode: 'subscription' instead of payment. In your webhook, try listening for customer.subscription.created or customer.subscription.updated events and updating the user’s plan in your database when you receive them.

If the database is not being updated, the redirect URL alone may not give the user premium access even if Stripe shows the payment as successful. That could be the root cause of the issue. Just a thought! I’ve dealt with something similar before.

2 Likes

Yes! A product and subscription was created within Stripe in Test Mode.

Are you seeing the subscription as active for the customer in Stripe test env?

Thank you! I checked and confirmed in the code that it has mode: ‘subscription’. Webhook is already set for listening for customer.subscription.updated events. Yes, I’m seeing the subscription active for the customer in the Stripe Test Mode. But it still shows them as a free user in the deployed Replit site.

What are you using for auth?

Good question! I don’t know. It’s just a login username/password currently. But here to learn.

I suspect this may be your problem. You’re maybe storing auth in memcache, and it’s not properly handling login/tokens.

Try setting up Firebase auth and tell Agent to set it up for you. You can follow my video here: https://youtu.be/eBUC_kWzKbc

Watch til the end because I forget the most basic part til then, sorry!

If you need help, circle back here and I’ll get you squared away.

To handle subscriptions/users/logged in state you really need a solid auth system, and it’s something that’s always been a struggle with Replit.

I’ve had nothing but success using Firebase as explained in the video, and, it’s free!

Thank you for this! Great to know.

When I had Claude Sonnet 4 take a look at some of the code in Replit. It said this,

Problem 1: Session Data Staleness

// ❌ ISSUE: After Stripe payment, session still contains old user data // The webhook updates the database but NOT the user's active session //

Current flow:
1. User pays via Stripe ✅
2. Webhook updates database ✅
3. User redirected to dashboard ❌ (still has old session data)
4. Dashboard shows FREE instead of PREMIUM ❌

Problem 2: No Session Refresh Mechanism

Your /api/auth/refresh-session endpoint exists but has issues

The Problem

Your Stripe checkout success URLs are pointing to static pages that don't refresh the user's session data. The webhook updates the database correctly, but the user's browser session remains unchanged.

The Solution

You need to create a session refresh endpoint and update your Stripe checkout success URLs to use it.

So I’ve added the session refresh endpoint codes that it had written. But seems to be still the same result with paid users landing on the free account dashboard. Perhaps I added the code incorrectly - I’m not sure? But would this be the issue in addition to not having Firebase to cause it?

This sort of confirms my suspicion, that you don’t have proper session handling configured. Did you try Firebase?

I think it will solve your problem.

I am looking at Firebase now. Does the free tier work or would I need to do a subscription? Once it’s integrated with Replit, does that mean Firebase will manage the database and all the backend rather than in Replit, or just the authentication part? Just trying to understand all the pieces and where things will be. Thank you!

Free tier works fine.

I use Firebase for auth only, not for database. I use Postgres within Replit for data. You can manage auth/users from your own admin interface if you choose to build it on Replit, but you’ll need admin sdk from Firebase to do so. Getting admin sdk keys is covered in my video.

1 Like

Perfect, thank you so much. I’ve followed the video steps and have created a Firebase account. Starting to ask the Agent in Replit to integrate it now. Crossing fingers this fixes it.

Let me know what happens, I’ll help you through it.

So I’m testing it now now. I added my real domain name to the Firebase Authorized Domains section/page. But when I click to login by Google email, it gives me a 404. Does the domain need to be the defaulted “[projectID].firebase.app” one?

You need to add repit.dev and replit.app to authorized domains.

Enable username and password as well as sign in with google in Firebase, and tell Agent to make sure both are enabled on your end. Agent also should be told that you want to make sure firebase users are synced with postgres users, and you want to be able to CRUD from your admin interface. It’ll then ask you for the firebase admin sdk JSON (full copy/paste of the contents of that file, usually).

Add your full replit dev URL to auth domains in firebase as well