I am trying to integrate the Stripe Customer Portal via a portal session
on our Webflow Member page. A portal session
is the entry point into the customer portal. It provides a unique, temporary link to the portal.
I know third-party tools can do that as well, but I don’t see the point of paying $300+ for that when it’s possible with some lines of code, and I don’t need subscription management.
The Stripe documentation (Integrate the customer portal with the API | Stripe Documentation) states:
- Add a button that customers can click to enter the portal. Use a POST request to create a portal session:
<form method="POST" action="/create-customer-portal-session">
<button type="submit">Manage billing</button>
</form>
- Add an endpoint that creates a portal session and redirects your customers. Make sure to authenticate customers on your site before creating sessions for them. To create a session, you need the customer’s ID (already added as a custom field to each WF Member account) and a return_url (in our case domain[dot]com/user-account) , which is required if a default return URL isn’t set in the Dashboard configuration.
When we create a portal session, Stripe returns the portal session object
, which contains the session’s short-lived URL that our customers use to access the customer portal.
And then follows a code block to initiate the session:
curl https://api.stripe.com/v1/billing_portal/sessions \
-u sk_test_XXXXX: \
-d "customer"="{{CUSTOMER_ID}}" \
-d "return_url"="https://domain.com/user-account"
Adding a button to the page is straightforward. What I am struggling with the most is how I can initiate the session and how I can integrate the code block to authenticate the portal session.
Thank you a lot for your help on this. Really appreciate everyone who takes the time to answer this post.