Discourse Subscriptions

:discourse2: Summary Discourse Subscriptions allows site owners to sell recurring and one-time purchase subscriptions that grant access to a group on a Discourse instance.
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-subscriptions
:open_book: Install Guide How to install plugins in Discourse

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.
    • To add a description to your product, add a metadata field named “description” and use that one instead. You can use Markdown.
  • 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 Payment Gateway (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: Test payment methods | Stripe Documentation

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.

Settings

Name Description
discourse subscriptions enabled Enable the Discourse Subscriptions plugin.
discourse subscriptions extra nav subscribe Show the subscribe button in the primary navigation
discourse subscriptions public key Stripe Publishable Key
discourse subscriptions secret key Stripe Secret Key
discourse subscriptions webhook secret Stripe Webhook Secret
discourse subscriptions currency Default Currency Code. This can be overridden when creating a subscription plan.
discourse subscriptions campaign enabled Enables a campaign banner to promote supporting this community financially.
discourse subscriptions campaign goal The numerical goal for your support campaign (subscribers or amount raised).
discourse subscriptions campaign type Selects the type of campaign to run (subscribers or monthly amount raised).
discourse subscriptions campaign banner location Selects the location of the campaign banner (top or sidebar).
discourse subscriptions campaign banner bg image Upload a custom image to use as the background on the campaign banner.
discourse subscriptions campaign banner shadow color Selects the color of the campaign banner drop shadow.
discourse subscriptions campaign show contributors Show avatars of the most recent purchases of subscription products.
discourse subscriptions campaign product The Stripe product id to send supporters when they click the button on the campaign. If this setting is blank, supporters will be directed to the main products page.
discourse subscriptions campaign grant Grants the user a free month of subscriptions
discourse subscriptions pricing table id The Stripe pricing table id from the embed code
discourse subscriptions pricing table enabled Enables using the Stripe pricing table and replaces the existing subscribe page

:discourse2: Hosted by us? This plugin is available on all of our hosting plans Subscriptions | Discourse - Civilized Discussion

128 Likes

I am missing something. Please point me in the right direction.

I can see products I created in Discourse in Stripe and have setup payment links with a trial period. I am not requiring cc to be collected up front.

But this is not actually getting people into my discourse forum? I’m sure I’ve missed an important detail, but I can’t figure it out. I’ve asked the folks at Stripe and they say it’s not their issue.

What is the process to put someone in the group after they have purchased a subscription membership?

My goal is that they have access to the forum only as long as they renew their membership.

1 Like

Did you actually create the group and assign it with the plan?

that still feels like a very manual process to oversee.

Yes, I have products in discourse. They show up in Stripe
I have a group called subscribers.
Payment links in Stripe… but there is nothing that seems to add them to the group once they purchase unless I do it manually by sending them an invitation.

Stripe told me to give them a link to the group in the purchase confirmation. But if they then later cancel, that seems like I have to manually remove them.

is this process not automated?

It should be. Can you double check that your payment plan is assigned to a group and not to “no-group”:

Screenshot 2024-03-07 at 9.13.27 AM

3 Likes

Yes, It is set to the appropriate group:

When I try this process in stripe (using the payment link), nothing happens, other than collecting their contact info. There is nothing that sends them to Discourse (unless I add a manual link on the confirmation page).

I’m wondering if not collecting a cc is part of the problem – but I have created, deleted and create new products / product links, payment plans, etc multiple times now without this working.

They should place the order from Discourse at /s/product_id. If you’re sending them to stripe to place the orders, Discourse doesn’t know about it.

If you set up webhooks, they’ll be automatically removed from the group when the subscription ends.

Is there someone who could look at my configuration (zoom?) and help me sort this out?

1 Like

Ok, now I’m really confused! I thought we had to use stripe? Hence the API requirements.

So how would someone get access to a product in discourse unless they are already in discourse? Or unless I send them an invitation that seems to make it unlimited free access.

I’m usually not this thick skulled on technology :slight_smile: This just doesn’t make sense to me based on instructions.

Do you mean a payment link that you generated in stripe, or a link you get from yoursite.com/s?

The idea is that you’d have a category which is only visible to people in the Subscribers group. That might be the only category on Discourse, if you want to lock it down to subscribers, I suppose. But you might want to include another category that’s visible to everyone explaining the purpose of your site.

So you can invite anyone could join Discourse, but they only see the public shell unti they pay to subscribe.

if I go to myite.com/s this is what I see: Nothing is clickable.

Then you have no active subscriptions.

That may be true – I’ve been round and round in circles without being able to configure anything differently. And I really don’t understand the stripe pieces of the puzzle now.

Those “Active” subscriptions should show up at /s, so maybe look again?

friend, I have been looking at this for 2 days. It’s not there. Something is clearly not working properly. And I cannot find any instructions that suggest how to troubleshoot it.

2 Likes

I’m looking at some things locally, and I’ll get back to you.

5 Likes

Thank you @jericson for looking into this.

Looks like there is currently a conflict with an experimental site setting that was just announced: Content-Security-Policy now uses 'strict-dynamic'.

Until a fix for the subscription plugin is in place you will need to make sure content security policy strict dynamic is disabled.

9 Likes

Actually a fix was created yesterday, it just hadn’t been deployed everywhere yet.

@danabrig Your site was just deployed as well with this this fix, so it should be working again now. Sorry for the troubles.

9 Likes

I’ve got a minor UI bug where the value of cents in the amount raised is truncating the hundredths place when its value is a zero.

screenshot

Not a functional issue or really a big deal, but annoying enough that two people asked me about it. :slight_smile:

3 Likes