A Discourse plugin that allows payments and subscription management via Stripe.
Go to file
Rimian Perkins 333f9c694c
Create FUNDING.yml
2020-01-31 11:19:54 +11:00
.github Create FUNDING.yml 2020-01-31 11:19:54 +11:00
app add the user to the group if subscription is completing 2020-01-26 10:49:51 +11:00
assets whoops prettier complaint 2020-01-14 20:15:54 +11:00
config respond to incomplete payment 2020-01-14 18:46:48 +11:00
db/migrate rm old migrations 2019-12-05 17:11:05 +11:00
doc update some images 2019-12-17 19:49:08 +11:00
lib/discourse_subscriptions name space module 2019-12-04 11:23:45 +11:00
spec add the user to the group if subscription is completing 2020-01-26 10:49:51 +11:00
test/javascripts test buttons show 2020-01-12 09:08:00 +11:00
.eslintrc appease eslint 2019-08-27 20:18:02 +10:00
.gitignore update .gitignore 2017-10-08 23:18:22 +01:00
.ruby-version upgrade ruby 2019-08-25 11:51:06 +10:00
.travis.yml enable discourse-plugin-ci 2019-08-27 19:52:25 +10:00
LICENSE Initial commit 2017-01-30 10:52:35 +11:00
README.md small edit to link 2020-01-28 09:13:47 +11:00
jsapp add success handler 2019-09-12 07:43:27 +10:00
plugin.rb bump 2020-01-28 09:11:15 +11:00

README.md

Discourse Subscriptions

Build Status

The Discourse Subscriptions plugin allows you to set up a subscription based Discourse application. By integrating with the Stripe payment gateway and setting up this plugin to manage Subscriptions, you can start selling users access to content on your website.

You can try it out here: https://discourse.rimian.com.au/s/subscribe

See Screenshots below.

Sponsorship

This project is partly funded by discourse.org. Many thanks!

If you too would like to sponsor this project, I'd really appreciate it. You can help with development, admin costs or just coffee budget. See here: https://github.com/sponsors/rimian

Installation

##Settings:

You'll need to get some info from your Stripe account to complete the steps below: https://dashboard.stripe.com/

  • Add your Stripe public and private keys
  • Set the currency to your local value.
  • Add your Stripe webhook secret.

See webhook info below.

What are Subscriptions?

Subscriptions are how you manage access to your content. There are two core components to make Subscriptions work for your Discourse application. These are Products and Plans.

A Product describes what the user gets when they subscribe. It has a name and description and most importantly, it is associated with a Discourse User Group. A product can have one or more plans.

A Plan is how you charge your users for the Product. Plans have rates, billing intervals and trial periods. A Product may have multiple Plans. For example: a yearly and a monthly Plan with different pricing. You can't change plans much once they are created but you can archive them and create new ones.

Together, Products and Plans make up Subscriptions.

It is important to note that ultimately, your subscriptions are managed by the Stripe payment gateway. Stripe will handle the billing, etc at the required intervals and notify your Discourse Plugin when something happens. If you were to destroy your instance of Discourse, you will need to cancel all of your subscriptions manually with Stripe. Thankfully, Stripe has a portal where you can manage all that.

How to set up your Discourse app for subscriptions.

Set up your payment gateway.

Firstly, you'll need an account with the Stripe payment gateway. This is how you manage your transactions.

When you get a moment, take a look at Stripe's documentation. But for now, you can set up an account in test mode and see how it all works without making any real transactions. Then, if you're happy with how everything works, you can start taking real transactions. See below for test credit card numbers.

Enable Webhooks in your Stripe account

You'll need to tell Stripe where your end points are. You can enter this in your Stripe dashboard. Also: Add the webhook secret in settings (above).

The address for webhooks is: [your server address]/s/hooks

Discourse Subscriptions responds to the following events:

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

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 and and remove users from the group you associated with your Plan.

After you have created a User Group and configured it correctly, you can move onto setting up Discourse Subscriptions.

Enter your configuration details

When you create an account with Stripe, you'll get a public and private key. These are entered in the Discourse Subscriptions admin so your subscriptions can integrate with Stripe. There are different keys for testing and production environments.

You can also toggle the Subscribe button on and off in case you want to hide the link while you're setting up.

Create one or more products with plans.

In the admin, 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:

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

Warranty

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Credits

Many thanks to Chris Beach and Angus McLeod who helped on the previous version of this plugin. Many thanks to the Discourse team who sponsored this plugin! You guys rock.

Screenshots

Products Admin

Admin Products

Product Admin

Admin Product

Plan Admin

Admin Plan

Subscription Admin

Admin Subscriptions

Subscription User

Admin Subscriptions

Payments User

Admin Subscriptions

Subscribe

Admin Subscriptions