vincent15000's avatar

Stripe configuration to have nothing to do on the application ?

Hello,

Hmmm ... well ... how to explain ?

I already noticed on some websites, if you have to pay for a subscription, you just have a button and you are redirect to a Stripe IHM where you can choose your plan, change it, download the invoices, ...

I'm searching without success how to do that.

Can you help me please ?

Thanks a lot.

V

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Certainly! What you’re describing is called the Stripe Customer Portal. This is a Stripe-hosted page where your users can manage their subscriptions, update payment methods, view invoices, and more—without you having to build all that functionality yourself.

Here’s how you can set it up:

1. Enable the Customer Portal in Stripe

  • Go to your Stripe Dashboard.
  • Navigate to Billing > Customer Portal.
  • Configure the portal: select what features you want your customers to have (manage subscriptions, update payment methods, download invoices, etc.).

2. Create a Portal Session in Your Backend

You need to create a session for your customer and redirect them to the Stripe-hosted portal. Here’s a simple example in PHP (using Laravel, but the logic is similar in any backend):

use Stripe\Stripe;
use Stripe\BillingPortal\Session;

Stripe::setApiKey(env('STRIPE_SECRET'));

$session = Session::create([
    'customer' => $stripeCustomerId, // The Stripe customer ID for your user
    'return_url' => 'https://your-app.com/account', // Where to send them after they're done
]);

return redirect($session->url);

3. Add a Button in Your Frontend

Just add a button or link that calls your backend route to create the portal session and redirects the user.

<a href="/billing/portal" class="btn btn-primary">Manage Subscription</a>

4. That’s It!

When the user clicks the button, they’re redirected to Stripe’s portal where they can manage everything themselves. You don’t have to build or maintain any subscription management UI.


Docs for reference:

Let me know if you need a more specific example for your tech stack!

1 like

Please or to participate in this conversation.