Discourse Subscriptions

:mega: Summary: Discourse Subscriptions allows site owners to sell recurring and one-time purchase subscriptions that grant access to a group on a Discourse instance.

:link: GitHub: https://github.com/discourse/discourse-subscriptions
:arrow_right: Install: Follow the plugin installation guide.

Features

Discourse Subscriptions supports the following features:

  • Create new products and plans from the admin panel
  • Cancel and refund subscriptions from the admin panel
  • Create one time purchase or recurring subscription plans
  • Add free trials on recurring subscriptions
  • SCA/3D Secure support
  • Add/remove users from plan groups as they subscribe/cancel
  • Cancel subscription from user profile
  • Cancellation of subscription at end of subscription period

Terms

  • Subscription - Subscriptions are a recurring payment plan which allow you to control access to content on your community. When a subscription is created or deleted, a user is added or removed from the user group you associate with your subscription plan. A subscription is made up of a product and plans.
  • Product - A product in Stripe’s terms is what you’re selling. A product can contain one or more plans.
  • Plan - A plan contains a price, recurring cycle, and associates with a group to which your subscribers gain access.

:rotating_light: Be very careful to keep your Stripe private keys safe and secure at all times.

:warning: If you were to shut down your instance of Discourse, uninstall this plugin or your site were to go offline, Stripe will continue to bill your customers for your service until the subscription is cancelled.

Configuration

  1. Install & enable the plugin
  2. Configure Stripe
  3. Configure Webhooks & Events in Stripe
  4. Add your Stripe keys (public, secret, webhook secret) under Admin > Plugin > Settings
  5. Create a group for your subscribers to join via purchase
  6. Create a product and plan under Admin > Plugins > Subscriptions
  7. Profit!

Set up your Payment Gateway.

Firstly, you’ll need an account with the Stripe payment gateway. To get started, you can set up an account in test mode and see how it all works without making any real transactions or having to set up a bank account. There is no test mode toggle in the plugin; instead, be sure to use your developer keys (they begin with pk_test, sk_test)

Set up Webhooks and Events in your Stripe account

:bomb: Webhooks are required to make subscription cancellations work fully. Be sure you have them configured correctly.

Once you have an account on Stripe, you’ll need to tell Stripe your website’s address so it can notify you about certain transactions. You can enter this in your Stripe dashboard under Endpoints > URL.

Webhooks address: [your server address]/s/hooks – where [your server address] is the URL of your Discourse install.

You’ll also need to tell Stripe which events it should notify you about via the webhook URL.

Currently, Discourse Subscriptions responds to the following events:

  • customer.subscription.deleted
  • customer.subscription.updated

Add the Stripe API and Webhook keys to your plugin settings

Stripe needs to be authorized to communicate with your website. To do this, it publishes a pair of private and public API keys and a signing secret for your web hooks.

To authorize webhooks, add the API keys and webhook secret from Stripe to your settings page (under Developers).

:warning: Adding production keys will make live payments. If you plan to test, be sure to switch to View test data mode and get pk_test and sk_test keys under Developers.

In your Stripe account settings, see:

Add these keys under the appropriate settings in Admin > Settings > Plugins.

Set up your User Groups in Discourse

When a user successfully subscribes to your Discourse application, after their credit card transaction has been processed, they are added to a User Group. By assigning users to a User Group, you can manage what your users have access to on your website. User groups are a core functionality of Discourse and this plugin does nothing with them except add and remove users from the group you associated with your Plan.

Create one or more products with plans.

Under Admin > Plugins > Subscriptions, click add a new Product. Once you have a product saved, you can add plans to it. Keep in mind that the pricing and billing intervals of plans cannot be changed once you create them. This is to avoid confusion around subscription management.

If you take a look at your Stripe Dashboard, you’ll see all those products and plans are listed. Discourse Subscriptions does not create them locally. They are created in Stripe.

Testing

Test with these credit card numbers:

  • 4242 4242 4242 4242
  • 4111 1111 1111 1111 (no authentication required)
  • 4000 0027 6000 3184 (authentication required)

For more test card numbers: https://stripe.com/docs/testing

Visit /s and enter a few test transactions.

Going Live

Once you’re ready to go live, change your API and webhook secret keys to production keys. You will need to create new products and plans in live mode.

Do be aware that if if you don’t properly configure Stripe webhooks, and recurring payments fail to process for any reason (expired credit card, etc.), users will still have access to the group . To have Stripe automatically cancel subscriptions, be sure to set your Manage failed payments settings similar to the below image and configure webhooks as described above.

CHANGELOG

  • 2021-06-02T05:00:00Z Support campaigns added
  • 2021-01-13T06:00:00Z Coupon code creation in admin panel
  • 2021-01-07T06:00:00Z Coupon code support (client only, creation required in Stripe)
  • 2020-11-02T06:00:00Z Subfolder install support
  • 2020-10-30T05:00:00Z Refund subscriptions from admin panel
  • 2020-10-29T05:00:00Z Improve anonymous user UX

TODO #pr-welcome

  • Extend rake subscriptions:import to migrate from other tools

:exclamation: If you were running this plugin prior to 2020-05-22T05:00:00Z, you may need to import subscriptions created by the plugin using the rake task rake subscriptions:import. This will pull products from Stripe, let you choose which to import, and subsequently import the related subscriptions to your site.

90 Likes
Steady plugin for community funding
Group membership subscriptions with profit split
ProCourse Memberships :money_with_wings:
Email drip campaign
Advertise activity in a private category (discourse-category-lockdown)
How to move Topics in Category into their own Pinned Topic inside new Categories?
User Card Directory
Options to manage payments for paid Discourse communities
Using a plug-in to monetize my Discourse
ProCourse Memberships :money_with_wings:
Login required after some days of free access
Plugin to use Discourse for classified ads or as a job board?
Allow users to donate to pay hosting fees for a site
API POST for New User
ProCourse Memberships :money_with_wings:
Advertise activity in a private category (discourse-category-lockdown)
Platform integration - videos
Discourse for Membership Association Members?
Any way to accept paypal or stripe payment at signup?
Multiple paywalls with common communication hub
Looking for feedback on Discourse Subscriptons
WooCommerce Discourse Website newbie help
Switching to Discourse Subscriptions from WordPress Subscriptions
Integration with Wix.com membership to only let the paid member can access to Discourse
Please suggest a good Discourse Plugin for Membership that supports Indian Payment Gateway
Changing excerpt length
Send an invite to a user but complete their profile programmatically
2020: The Year in Review
Managing Subscriptions through Wordpress (Ultimate Member + Paid Memberships Pro)
Install Plugins in Discourse
How to give unpaid users limited access without making Discourse private?
Lock topics behind a "crypto" paywall
Add user to group after purchase

Please make sure your app.yml has the correct repository installed. It should be https://github.com/discourse/discourse-subscriptions

6 Likes

This seems counterintuitive – shouldn’t the plugin automatically remove group access upon subscription renewal failure? Just about every other subscription system does this so I’m a little confused by this.

Ray

5 Likes

Yes as long as Stripe is set up to cancel subscriptions after failed charges AND you have webhooks set up correctly, it will work as expected.

6 Likes

I think I see, so maybe this:

should be something like

Also, it’s a little confusing that the OP is owned by @rimian, especially since the plugin is now official and he’s not @team. I think it’d be better if it were owned by you, or perhaps @system as some topics are, or perhaps a @discourse user should own #official things.

6 Likes

I would have if I were sure that I understood. :wink:

OK. Done.

This moves this from a bug/feature problem with the plugin to a user error.

I’m hoping to have a test site using this plugin up in the next week or two. . .

7 Likes

The only way to do this right now is with the rake subscriptions:import task. This was built to handle an edge case after a refactor, though I’m open to additions. #pr-welcome!

Plans should be able to be deactivated in the edit screen.

https://github.com/discourse/discourse-subscriptions/blob/0b5f740db546286b130ecaa890103bde9c30bdb2/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.hbs#L89-L94

Yes - it will cancel at the end of the subscription period. This is only valid for recurring items, though. If a one time purchase is refunded, group access will need manual removal.

7 Likes

@ajmuir @pfaffman it’s not 100% ready yet. I have some feedback to implement on the PR and have been focused on other things. Will be merged this week though!

It’s on the list!

8 Likes

Hey Justin. Since you’ve taken this over, I think it’d make sense if the OP changed ownership (you could include a reference to the fact that someone else started the plugin, but it does seem like yours now!). But that’s not why I’m writing.

I’ve said it before, but I’m really close to making semi-public a plugin that I’ve made that uses subscriptions to replace WordPress as the tool that I use for people to get my script to install Discourse for them. When they purchase a “server”, they are added to the group, and my plugin uses a GroupUser callback to create the server in my plugin’s model and then remove them from the group (so they can purchase another server). This all (?) works as expected.

And I’ve now adopted code in the custom header links theme component to add links to their server(s) after they are created. It even does differnt stuff if the server is “new” and if it has not yet been configured/installed.

The remaining problem is that after you make the purchase the purchaser can’t tell that anything has happened. I’d be happy enough if I knew how to do a window.location.reload(true); when a subscription had been purchased so that the link would show up at the top of the page. But it seems that having a field that you could customize some text like "Thanks for your purchase! Now you can see this category and see this link for more information about your subscription`. Or something like that.

Or maybe I should try again to submit a PR with some plugin outlets for me to be able to do stuff like this? (I figured it out once, but wasn’t quite sure just what plugin outlets really made sense, and now my fork is way behind.)

6 Likes

In case anyone is wondering, while Subscriptions don’t cancel in stripe until they were originally scheduled to end:

You can tell Stripe to cancel immediately (as perhaps in the case of a refund):

Stripe will then tell Discourse via the webhooks to remove the user from the Subscription group as you will probably want.

Stripe Customer refunds are a separate, independent step from cancelling Subscriptions.

5 Likes

I’ll have a look at this. You’re right - moderators shouldn’t have access.


Wanted to announce a new feature

Campaigns! You can now show a “Support our site” banner and take donations, tracking one of two different types of goals (subscribers or amount raised). This is perfect if you have a recurring hosting cost you’d like to try to get covered.

Additionally, we’ve made it super easy to start a campaign. Once your Stripe public, secret, and webhook keys are set up, click the Auto-Create Support Campaign button under Admin → Plugins → Subscriptions to generate everything you need with one click.

We’ll be working on updated documentation for all of this soon, too.

9 Likes

PR is up for this here.

PR up to fix this here:

EDIT: These PRs are merged.

5 Likes

Is there any way to use the theme hooks or another mechanism to add a block of HTML between the subscription page header and the list of subscription products?

We are using a membership subscription model to support our organization, but memberships can also be given for free if people can contribute to our efforts in other ways.

I would like to add a text that explains that so that people know that they can become a member without paying if they help out in other ways.

4 Likes

There aren’t any plugin outlets currently, but we’d happily accept a PR to add them in where necessary.

4 Likes

Awesome, thank you! I will look into adding that and submit a PR when done. It would be a good way to get my hands dirty with some initial plugin development =)

Are you specifically referring to making a PR for this plugin, or to Discourse as a whole?

1 Like

Just the plugin. Once you have a PR open, ping me here and I’m happy to chat through details :smiley:

1 Like

Here’s an example of how inserting the plugin outlet would look like in a fork of the plugin:

I did this a while back but never got a PR together and now I think it’ll be a bit of work to reconcile my changes with the current version of the plugin.

You just need to decide where you want to add your changes, come up with a name for each place, and add a line like the highlit one above.

You can then refer to those plugin outlets in themes the way that I think you already understand better than I do.

3 Likes

How do I extend someones subscription?

We had an issue with the site where certain members were seeing ads when they should not have been.

Hey there,

I installed the Subscriptions plugin and I don’t see this:

I am quite new at this and not sure what to add here for anyone to be able to help me along…

Looking forward to learning and appreciate any help you can offer :sparkles:

1 Like

Welcome Alexandra! :smiley: :wave:t5:

Can you share a screenshot of that page of your site so we see what you see?

1 Like