Skip to main content

Starts at 0:05, after the intro.

Lesson 6 of 8 · 7:47 · Advanced · Webflow

Let members pause instead

A pause button so members can stop billing for a while instead of cancelling.

Where this fits

A discount is one way to keep someone. Some members just need a break, so this lesson lets them pause billing instead of cancelling.

By the end of this lesson you can

  • Let members pause their subscription for a set number of months
  • Show active, paused and no subscription states with attributes
  • Let members resume early with a Resume button
  • See the paused collection in Stripe

Heads up: This one needs a small backend. You clone a GitHub repo, deploy it on a free Vercel account, and keep your Stripe and Memberstack secret keys there.

Lesson notes

How it works

Why pausing needs a small backend

Pausing a Stripe subscription needs your Stripe secret key, and a secret key can never sit in your website's code. So MemberScript #246 comes with a tiny backend you host on Vercel. It holds your Stripe and Memberstack secret keys, and the browser never sees them.

When a member clicks Pause, the script sends their Memberstack login token and the number of months to the backend. The backend checks the token with the Memberstack Admin API, works out their Stripe customer from that verified token, and pauses payment collection on their subscription. Because the customer comes from the token, a member can only ever pause their own subscription. Billing resumes on the chosen date, or earlier if they click Resume. The backend has three endpoints: /api/status, /api/pause and /api/resume.

Deploy the backend on Vercel

  1. Clone the memberscript246 GitHub repo and create a new Vercel project from it (free account is fine).
  2. In Vercel, open Settings, Environment Variables and add STRIPE_SECRET_KEY (Stripe, Developers, API keys) and MEMBERSTACK_SECRET_KEY (Memberstack, Dev tools).
  3. Redeploy so the keys take effect, and copy your project URL.
  4. Start with Stripe test keys and a test subscription, then switch to live keys.

Build the pause card in Webflow

Paste MemberScript #246 into the page where members manage their account. On the section add data-ms-code="pause-subscription" and ms-code-api with your Vercel URL (with https://, no trailing slash). Optional settings: ms-code-months="1" (default length), ms-code-max-months="12", ms-code-behavior (void by default: invoices during the pause are voided, so nothing is charged) and ms-code-price-id with a Stripe price_ ID if members can have more than one paid plan. Use the Stripe price ID, not the Memberstack prc_ ID.

Inside, build three states. data-ms-code="when-active" holds a select with data-ms-code="pause-months" and a button with data-ms-code="pause-btn". data-ms-code="when-paused" holds a date with data-ms-code="resumes-at" and a button with data-ms-code="resume-btn". data-ms-code="when-no-subscription" shows to members with no active subscription. Add pause-loading and the pause-message-success, pause-message-error and pause-message-info messages; the script fills and shows them.

Before you move on

0 of 5

Tick these off on your own site. Done with all of them? You’re ready for the next lesson.

Up next: Next, you’ll reach members who already cancelled with a banner that invites them back.

Chapters

Common questions

Can members pause their Memberstack subscription without the Stripe portal?

Yes. MemberScript #246 adds a pause button to your own page. A small Vercel backend pauses payment collection in Stripe for the number of months the member picks.

Is it safe to put my Stripe secret key in this setup?

The keys only live in your Vercel environment variables. The browser sends the member's login token, and the backend verifies it before touching Stripe.

What happens when the pause ends?

Stripe resumes collecting payments automatically on the resume date. Members can also resume early with the Resume button.

Keep going

Checked against the Memberstack docs

TranscriptAuto-generated captions
  1. 0:01

    Hi, my name is Memberstack, and welcome to MemberScript 246. In this video, I’ll show you how to allow your members to pause and resume their active subscriptions. So, I already have a subscription that I signed up for here, and you can see that I have paused my subscription for now. So I’ll just restore it like this . And the user will be able to see a card that looks like this . So, users will be able to pause their subscription for periods of 1 month, 2 months, or 3 months.

  2. 0:31

    So, if I select 1 month and then click "pause" , I will see that my subscription will renew for a month. And you, as the administrator of your Stripe account, will also be able to see that a user has paused collections on a certain plan, like this , and that it will only resume from a certain date. So, to set all this up, you’ll need a few things. First, you will need to

  3. 1:01

    clone this GitHub repository. After cloning, you need to create a new Vercel project. The purpose of creating a new Vercel project is so that we can get a specific URL that we will use inside Webflow. So, after cloning the repository or following all these steps, you will need to add some secret keys to your Vercel project. It will look something like this . So,

  4. 1:33

    inside your project, you’ll go to the environment variables and then add your Memberstack secret key and just mark it as confidential. It would look something like this: you add a key, a Memberstack secret key , and then a value, and you do the same for your Stripe secret key right here. So, your Stripe secret key, here’s where you’ll find it under the " Stripe Developers" and "API Keys" sections, and both of those need to be added to your

  5. 2:03

    Versel project for this to work. Once you’ve cloned the GitHub repository, created your project, and added environment variables, we’ll jump into Webflow, configure it, and show you how it all works. So, inside Webflow you will need to add Memberstack 246 and it should look like this. If you’re watching this on YouTube, the link to this code should be in the description below, and if you’re watching this on the Memberstack website, you should have already

  6. 2:33

    seen this code. You can add it site-wide on a specific page, depending on your specific use case , but ideally add it to the page where the user profile settings are located. So, on the page itself, you will need to add a few um attributes to make this work. First, the section above is just a demonstration section, so you can ignore it. The section we will focus on is called the " pause section." Okay, so the entire section has

  7. 3:03

    a few attributes that you will need to add, namely: MS Code Pause Subscription Data and then MS Code API . This is where our link to Vercel comes in handy. You can see that mine is a stack of participants, uh , participant script 246, um-vercel-API, etc. And you can also check here in Vercel that this is the exact link we are using. Okay, once you’ve

  8. 3:33

    added that, you can move on to the next attributes, which are: Number of months of MS code—one, and Maximum number of months of MS code—12. So the next variable or attribute would be the behavior of the MS code , set to void, and the price of the MS code would be the price at which you allow users to essentially pause and resume. This last attribute is specifically for cases where you allow users to pause and resume

  9. 4:03

    many or multiple paid plans at the same time. This attribute is completely optional. If you don’t have multiple paid plans that you allow users to pause, then you can remove this attribute. But the point here is you need to get or retrieve this price ID from Stripe itself. So, inside Stripe, you go to the product catalog, click on the product, and then you see the price here. And then, inside the price, you’ll

  10. 4:34

    see the price ID, and that’s what you copy into Webflow here. Okay, so inside the script here at the very top, you’ll see a brief description of all these variables and what they actually are, all these attributes and what they actually do. Okay, so let’s move on to the component itself. So, at the top we have a loader, and it’s optional, but this loader has the

  11. 5:04

    attribute of suspending the loading of MS code. And then another container for the pause state. The entire div has an attribute to pause loading the MS data code when it is active, and this will be displayed when the user has an active subscription. Good. Inside of this we will add this form. Then, you will add a select field to the form. The selection box will then be set to whatever number of

  12. 5:33

    months the user wants to suspend their subscription for . So, in this case, it’s 1, 2, and 3 months. You can set this to any number of months that the user should pause their subscription. Good. So, the pause button has a pause button attribute with MS code data. And then we will go into a pause state. So, when a user has paused their subscription, this is the status they will see. And it has a data attribute of MS- code during pause. And then inside of it we have a

  13. 6:02

    little message that will contain the date. The date has the data attribute of the MS code to restore it. And then our button has the data attribute of the MS-code of the restore button. And finally, at the very bottom, we have the “ unsubscribed” state. And it has a data attribute of MS code when there is no subscription. So, if a user doesn’t have an active subscription, this is what they will see. At the very bottom, we have a few "um" type messages

  14. 6:33

    that the user will see when they succeed in pausing their subscription, when an error occurs, or just a general informational message. And all these messages are dynamically filled in by the script. All you need to do is make sure they are on the page and have the success message attributes: data ms code pause message success. Error will be pause message error. And then info will be pause message info. OK. So, that’s all.

  15. 7:05

    The most important thing is to make sure your Vercel um API link is correct here. And if you have multiple paid plans, make sure you add the price ID to this section for the appropriate plan. OK. So, once you have all of this set up, you have a way for users to actually pause and resume their subscriptions without having to contact you or your support team. So if you have any questions

  16. 7:35

    about this, please reach out in the Slack 2.0 channel. See you later.

This is v1 of Memberstack University, built from the tutorials we’ve put so much work into over the years. We’d like to make a more organized series.