Skip to content

Stripe Subscriptions

Original guide · All levels

Intro With Stripe you can setup subscriptions and checkout pages, where your users can subscribe for your services or products. Subscriptions and Prices The first step is to setup your subscription(s)

With Stripe you can setup subscriptions and checkout pages, where your users can subscribe for your services or products.

The first step is to setup your subscription(s) in Stripe Dashboard. Go to: https://dashboard.stripe.com/ and click Products:

Add a name for your subscription. It will be displayed on the checkout page:

Section titled “Add a name for your subscription. It will be displayed on the checkout page:”

Optionally you can add an image to be displayed on the checkout page. We don’t want to add an image now.

Section titled “Optionally you can add an image to be displayed on the checkout page. We don’t want to add an image now.”

Scroll down to the pricing section. Set the pricing model to Standard:

Enter the amount your customers should be charged for the selected billing periond:

Section titled “Enter the amount your customers should be charged for the selected billing periond:”

You can add another pricing (in different currency) if needed:

Section titled “You can add another pricing (in different currency) if needed:”

You will need the price id for the checkout, so copy it:

Section titled “You will need the price id for the checkout, so copy it:”

You can use the client-side only flow for your subscriptions. This allows you to integrate Stripe Checkout on your site, without using any server-side code.

Make sure the Client-Only Integration is enabled in your Stripe account: Getting Started with Stripe Integration in Wappler

On our page we added a simple Subscribe Now button, which will be used by our users to subscribe for our services/products:

Click the Add New component button in App Structure:

Section titled “Click the Add New component button in App Structure:”

Open the Stripe Category and select Stripe:

Section titled “Open the Stripe Category and select Stripe:”

Enter your Publishable API key. It can be found on https://dashboard.stripe.com/apikeys

Section titled “Enter your Publishable API key. It can be found on https://dashboard.stripe.com/apikeys”

Select Client Side Only in the Flow Type menu:

Section titled “Select Client Side Only in the Flow Type menu:”

Enter the success and cancel URLs. These are the URLs where the users will be redirected after a successful payment or if they cancel the order during the checkout:

In the Line Items, paste the Subscription Price ID which you copied earlier from the Stripe Dashboard:

Section titled “In the Line Items, paste the Subscription Price ID which you copied earlier from the Stripe Dashboard:”

Now, let’s setup the Subscribe Now button. Click the button:

Section titled “Now, let’s setup the Subscribe Now button. Click the button:”

Select and add Checkout under the Stripe Component:

Section titled “Select and add Checkout under the Stripe Component:”

And you are done. Clicking the Subscribe button takes your users to the checkout page, where they can pay:

Section titled “And you are done. Clicking the Subscribe button takes your users to the checkout page, where they can pay:”

You can also create a server-side checkout it gives more flexibility and options than the client-side integration.
In our example we will show you how to work with logged users and get their details for the checkout.
In our example we will get the logged in user’s details - such as user email, from a database query.

We already created a login server action as usual (you already know how to do this) and added a global Identify step in Globals. We will use the Identify value to filter a query in the server-side checkout flow:

We call it - stripe_subscription. Right click Steps:

Section titled “We call it - stripe_subscription. Right click Steps:”

Add your users table and add the columns you need:

Section titled “Add your users table and add the columns you need:”

Open the Conditions tab, and select a column to filter by:

Section titled “Open the Conditions tab, and select a column to filter by:”

This is the id column. Select a dynamic value for the filter value:

Section titled “This is the id column. Select a dynamic value for the filter value:”

This is the id column.
Select a dynamic value for the filter value:

Open Stripe > Customers and select List Customers:

Section titled “Open Stripe > Customers and select List Customers:”

Open Stripe > Customers and select List Customers:

This will return a list of our Stripe Customers. We want to filter it using the logged user email, returned by the query step. Select the dynamic data picker for the Email:

And select the email value returned by the query step:

Section titled “And select the email value returned by the query step:”

If our user exists in Stripe, then its details will be available for steps after that. If the user does not exist it will be created.

The next step is to create the checkout session. Right click the List Customers step:

Open Stripe > Checkout and Create Checkout Session:

Section titled “Open Stripe > Checkout and Create Checkout Session:”

Here, we need to add the Customer info which we retrieve using the List Customers step. Click the dynamic data picker for the Customer option:

Then open the Items Type menu and select Prices ID List:

Section titled “Then open the Items Type menu and select Prices ID List:”

Using this option allows you to enter the Subscription Price Id here directly. Useful when we only have one subscription plan only (as it is in our example). If you have more subscription plans you can pass them dynamically from the front end Stripe component.

Click the add new list item button:

And paste your subscription price id here:

Section titled “And paste your subscription price id here:”

Don’t forget to fill your success and cancel URLs in the appropriate UI fields.

Section titled “Don’t forget to fill your success and cancel URLs in the appropriate UI fields.”

Then right click the Create Checkout Session step:

And under the Checkout Session step select id:

Section titled “And under the Checkout Session step select id:”

Enable Output for the Set Value step and save your API Action:

Section titled “Enable Output for the Set Value step and save your API Action:”

Close the Server Connect panel. Add a new component in App Structure:

Section titled “Close the Server Connect panel. Add a new component in App Structure:”

Close the Server Connect panel.
Add a new component in App Structure:

Open Stripe and select the Stripe Component:

Section titled “Open Stripe and select the Stripe Component:”

Enter your Publishable API key. It can be found on https://dashboard.stripe.com/apikeys

Section titled “Enter your Publishable API key. It can be found on https://dashboard.stripe.com/apikeys”

This is the stripe_subscription API Action which we just created:

Section titled “This is the stripe_subscription API Action which we just created:”

Select Checkout under the Stripe Component and add it:

Section titled “Select Checkout under the Stripe Component and add it:”

And you are done. Clicking the Subscribe button takes your users to the checkout page, where they can pay. If the customer exists in Stripe, the email will be filled in: