Discourse Subscriptions

:computer: Code on GitHub
:open_book: How to Install a Plugin

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

Features

Discourse Subscriptions supports the following features:

  • A credit card payment page.
  • A settings page to manage Stripe configuration.
  • Administration to create, update and view products, plans and subscriptions.
  • Setting the user group associated with the subscription.
  • Setting if the plan is recurring or one-time.
  • Cancelling a subscription from admin.
  • Adds and removes users from user groups when subscriptions are created or deleted.
  • Allows the user to cancel their subscription in their user profile.
  • Webhooks that update your website when an event occurs on Stripe.

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.

Setup Steps

  1. Install & enable the plugin
  2. Add your Stripe keys (public, secret, webhook secret) under Admin > Plugin > Settings
  3. Create a group for your subscribers to join via purchase
  4. Create a product and plan under Admin > Plugins > Subscriptions
  5. 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: 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 recurring payments fail to process for any reason (expired credit card, etc.), users will still have access to the group as the plugin does not currently handle this itself. To have Stripe automatically cancel subscriptions, set your Manage failed payments settings similar to the below image.


: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.

71 Likes

Hi,

Great plugin. Two things that I’m having trouble with:
1. One-time payments. Everything well until the end… when confirming the payment I get an empty dialog window with a confirm button and nothing else happens.
2. Choosing a billing interval. I’m stuck with just the monthly plan, when clicking on the down arrow nothing appears, no monthly, no anual, just a tiny blank stripe under.

Using discourse 2.5.0 beta1, Subscriptions plugin 2.8.0.

1 Like

Thanks for the feedback @Paracelsus. What browser are you using?

I’ve been using Edge on desktop, but had the same problem with Chrome on iOS.

The legacy version of Microsoft Edge?

All iOS browsers are essentially the same under the hood, so it’s likely that all browsers (whether on desktop or mobile) are affected.

Testing URL in para 2 doesn’t work.

Just tested with Firefox (desktop). Same thing.

I think that video you uploaded is helpful. I’m about to board a plane and won’t be around for a few days. If anyone else wants to do a PR, that would be great. If not, I will look soon. Thanks for your help!

1 Like

I don’t think so, but I’ll check again.

Meanwhile you can check in this video what happens when trying to choose the billing interval:

1 Like

If it helps:

From Microsoft Edge console:

Those are all normal deprecation messages and likely not relating to the issue you’re seeing.

5 Likes

Thanks for the plugin!

I have tested this plugin with latest Discourse source in development env.

I’ve set it up, created a product and a plan.

Billing interval only allows “month”.

image

I can’t get any page rendered under /s:

image

When I enable “one-time” payment is it possible to have plan without recurrent payment or how does it work?

When user gets removed from the user group? Only after webhook call from stripe? That seems like I could also add users to the group manually without being afraid that plugin removes them… Or am I wrong?

Thank you for this wonderful plugin! A couple thoughts:

  • How can I modify the $ amounts for the subscription…? Is that defined by the plugin or configured on Stripe?
  • Is it possible to add a description field by the amount so it is clearer to subscribers what they are supporting?
  • Is it possible to switch around options so that one-time payments vs recurring can be set based on amount sent. Example: under $40 per month is always one time. $40 - 160 is subscription default.
  • Is it possible to bring the $xx.xx and “Subscribe” button right next to each other? They are quite far apart and offset with our theme.
1 Like

Hi James

Stripe don’t allow you to modify a subscription plan amount once it has been created. This causes confusion for those who may already be on an existing plan.

I will add a description field hopefully soon.

You can always modify your existing css to move the buttons.

Stay safe!

4 Likes

@rimian Hi Rimian, Please remove the currency symbol $ as the prefix or use an appropriate symbol as per currency. Currently, My currency is INR and the plugin is showing as $INR 1250. Similarly, I have created a half-yearly plan in my stripe dashboard, which is being shown as Monthly. And dropdowns don’t work as expected.

As a temporary workaround for my issues, I’ve written the following javascript code to solve this.

<script>
$( document ).ajaxComplete(function() {
$('.subscribe-buttons button>.amount').each(function(i){ $(this).text($(this).text().replace('$',''))})
$(".subscribe-buttons button>.interval:eq(1)").html('Half Yearly');
});
</script>

Can I rely on it though? It would be much better the plugin itself doesn’t have these issues.
Please resolve these issues. Thanks :slight_smile:

If you are unhappy that the free software you are using doesn’t fit your needs…

12 Likes

One thing I noticed is that failed subscription payments aren’t handled by the plugin. The readme should mention that you need to make sure your Stripe settings will cancel subscriptions automatically, something like this:

10 Likes

Hi Raj,

I haven’t built support for INR or half yearly plans at this stage. I will build support for other currencies when I get the chance. If this is something you need soon, I could always review any pull requests for new features. This should resolve your dropdown issues too.

Thanks.

1 Like

Just pointing this out so that someone can pick this up, I have a UX suggestion here. When you head over to the /subscribe page, this is what you see when you’re not logged in:

  1. Unless there is another reason to keep this info secret, we could show them the tiers instead:

    When someone clicks Subscribe, we can pop the sign up / login modal. This would give us the ability to have a ‘selling’ type page for anon users like Patreon etc…

  2. If not this yet, we should display a better message like You need to be logged-in to view subscriptions offered by this Discourse instance for now.

19 Likes

@rimian I have created a PR, adding INR as a supported currency.

Thanks,

6 Likes