Discover with this tutorial how to create and give access for a Restrict Content Pro customer to the Stripe portal in order to manage their payment cards.
If you use Restrict Content Pro with the Stripe payment gateway you probably already know that the subscriber can modify some data from the web.
But it has its limitations, as sometimes subscribers have problems when trying to update payment cards. Also, the plugin only allows to save and manage one card.
The good thing is that we can overcome these limitations by taking advantage of Stripe’s customer portal.
This Stripe feature allows you to easily create a page where the customer can access and modify the data that you (as Stripe account administrator) give them access to.
In this tutorial I will explain how you can give them access to update, modify or add payment cards.
Let’s get started.
Steps to give access to the Stripe customer portal for a Restrict Content Pro subscriber to manage payment cards
1. Create the customer portal in Stripe
The first thing you are going to do is go to your Stripe account and visit the page where you set up the customer portal.
If you haven’t already done so, fill in your brand and company name information.
Then activate the features you want the RCP subscriber to be able to access. In this case, you have to activate “Payment methods”.
![Stripe customer portal configuration settings](https://osomcode.com/wp-content/uploads/2022/05/settings-configuration-portal-clients-Stripe.jpg)
Once you have configured the portal be sure to save the changes.
2. Create the logic that will show access to the portal
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
In this code you build all the logic that allows you to access the Stripe customer portal by clicking on a button.
Warning: If you are using a version of Restrict Content Pro lower than 3.5.15 the path you should use is /includes/libraries/stripe/init.php
instead of /core/includes/libraries/stripe/init.php
.
In order to create a session to access the Stripe portal you need the Stripe client ID. You get this from the user ID (using get_current_user_id()
).
The concrete process is: User ID > RCP Client ID > RCP Membership > Stripe Client ID.
In the snippet you also use the Stripe secret key, which in this case is stored within the Restrict Content Pro options ($rcp_options['stripe_live_secret']
).
Now there is only one step left.
3. Enter the form with the button that gives access to the portal
There is only one step left and that is to create the form with the button, which when clicked, creates a new session in Stripe and gives access to the customer portal.
Just add an HTML block with the following code:
<button type="submit" name="btn-customer-portal">Manage payment cards in Stripe</button>
</form>
You can place it between paragraph blocks where you explain what the customer can expect when clicking.
You can also customize the button message (“Manage payment cards in Stripe”) to your liking.
Conclusions
Now you know how you can leverage Stripe’s customer portal to give Restrict Content Pro subscribers access to manage payment cards.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉