discourse-subscriptions/README.md

150 lines
8.9 KiB
Markdown
Raw Normal View History

2019-12-02 02:58:14 -05:00
# Discourse Subscriptions
2019-09-11 05:24:25 -04:00
2019-12-02 02:58:14 -05:00
[![Build Status](https://travis-ci.org/rimian/discourse-subscriptions.svg?branch=master)](https://travis-ci.org/rimian/discourse-subscriptions)
2019-09-11 05:24:25 -04:00
2020-02-05 20:20:32 -05:00
The Discourse Subscriptions plugin allows you to set up a subscription based Discourse application. By integrating with the [Stripe](https://stripe.com) payment gateway and setting up this plugin to manage Subscriptions, you can start allowing users access to content on your website on a user pays basis.
2019-09-11 05:24:25 -04:00
2020-02-05 23:09:52 -05:00
You can test this plugin here: https://discourse.rimian.com.au/s. See testing section below for test credit card numbers.
2019-11-18 20:56:30 -05:00
2020-02-05 23:07:14 -05:00
This software offers [no warranty](https://github.com/rimian/discourse-subscriptions/blob/master/WARRANTY.md) of any kind.
2020-02-05 20:20:32 -05:00
### 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.
* 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.
2020-02-05 23:00:41 -05:00
See screenshots below.
2020-02-05 20:21:14 -05:00
2020-02-05 20:20:32 -05:00
### Sponsorship
2020-01-27 17:11:15 -05:00
2020-01-27 17:12:55 -05:00
This project is partly funded by [discourse.org](https://discourse.org). Many thanks!
2020-01-27 17:11:15 -05:00
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
2020-02-05 20:20:32 -05:00
## Plugin Installation
Follow the [plugin](https://github.com/rimian/discourse-subscriptions) install instructions here: https://meta.discourse.org/t/install-a-plugin/19157
2020-02-05 18:32:06 -05:00
## Core concepts
2019-09-11 05:24:25 -04:00
2020-02-05 20:20:32 -05:00
### Managing your Stripe Account
2020-02-05 23:00:41 -05:00
Ultimately, your Subscriptions are managed by the Stripe subscription portal. Stripe will handle the recurring billing, invoices, etc at the required intervals and notify your [Discourse Subscriptions](https://github.com/rimian/discourse-subscriptions) plugin when specific transactions happen.
2020-02-05 18:39:32 -05:00
2020-02-05 20:40:59 -05:00
This plugin does not store Stripe transaction or subscription details in your database other than the customer and product identifiers associated with those transactions. User group management is not stored in the stripe Portal.
2020-02-05 20:39:02 -05:00
Be very careful to keep your Stripe private keys safe and secure at all times.
2020-02-05 23:07:14 -05:00
**It is important to note** that 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. It is your responsibility to manage your customers and provide the service they are paying for.
2020-02-05 18:39:32 -05:00
2020-02-05 20:20:32 -05:00
Stripe has a [portal](https://dashboard.stripe.com) where you can manage all your customer's, payments and subscriptions.
2020-02-05 18:39:32 -05:00
2020-02-05 18:32:06 -05:00
### Subscriptions
2020-01-14 02:46:48 -05:00
2020-02-05 22:50:22 -05:00
Suscriptions are major feature of Stripe and this plugin's primary function is to leverage this feature by assigning Subscriptions to Discourse *user groups*. Subscriptions allow you to take payments and controll access to content on your website.
2020-01-14 02:46:48 -05:00
2020-02-05 20:20:32 -05:00
When a subscription is created or deleted, a user is added or removed from the user group you associate with your subscription. Please note: If you manually remove or add users to a user group via Discourse admin, you'll need to manage subscriptions for those users manually.
2020-02-05 18:32:06 -05:00
### Products
2020-01-14 02:46:48 -05:00
2020-02-05 20:31:42 -05:00
A Product describes what the user gets when they subscribe. It is basically a user group on your website. A product has a *name* and *description* and most importantly, it is associated with a Discourse User Group.
2020-02-05 20:20:32 -05:00
A product can have one or more *plans*.
2020-01-14 02:46:48 -05:00
2020-02-05 18:32:06 -05:00
### Plans
2019-09-11 05:24:25 -04:00
2020-02-05 20:31:42 -05:00
A Plan determines how and when 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.
2019-09-11 23:13:06 -04:00
2020-02-05 18:32:06 -05:00
Together, Products and Plans make up Subscriptions.
2019-11-18 19:36:36 -05:00
2020-02-05 18:32:06 -05:00
## Getting started with Discourse Subscriptions
2019-11-18 17:59:15 -05:00
2020-02-05 20:31:42 -05:00
To begin, you can install this plugin and try it out in test mode. You can disable the navigation link in settings while you're testing.
2020-02-05 18:32:06 -05:00
### Set up your Payment Gateway.
2019-11-18 17:59:15 -05:00
2020-02-05 18:32:06 -05:00
Firstly, you'll need an account with the [Stripe](https://stripe.com) 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.
2019-11-18 17:59:15 -05:00
2020-02-05 18:32:06 -05:00
### Set up Webhooks and Events in your Stripe account
2019-11-18 18:10:41 -05:00
2020-02-05 18:32:06 -05:00
Once you have an account on Stripe, you'll need to [tell Stripe your website's address](https://dashboard.stripe.com/test/webhooks) so it can notify you about certain transactions. You can enter this in your Stripe dashboard under **Endpoints > URL**.
2020-01-14 02:46:48 -05:00
2020-02-05 23:00:41 -05:00
The address for webhooks is: `[your server address]/s/hooks` where [your server address] is the URL of your discourse install.
2020-01-14 02:46:48 -05:00
2020-02-05 20:20:32 -05:00
You'll also need to tell Stripe which events it should notify you about via the webhook URL. You can select specific events or all of them. By allowing all events to be sent to your server, you don't have to worry about which events are important to you, but it will significantly load up your server and could cause problems with your site's availability. If you're concerned about this, only add the events below under **Webhook details**.
2020-01-14 02:46:48 -05:00
2020-02-05 18:32:06 -05:00
Currently, Discourse Subscriptions responds to the following events:
2020-01-24 23:06:05 -05:00
* `customer.subscription.deleted`
* `customer.subscription.updated`
2020-01-14 02:46:48 -05:00
2020-02-05 23:12:29 -05:00
**Warning:** Events supported by this plugin may change, in the future as new features are added to this plugin.
2020-02-05 18:32:06 -05:00
2020-02-05 20:20:32 -05:00
### Add the Stripe API and Webhook keys to your plugin settings
2020-02-05 18:32:06 -05:00
Stripe needs to be authorised 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.
2020-02-05 20:20:32 -05:00
To authorise webhooks, add the API keys and webhook secret from Stripe to your settings page (under Developers).
In your Stripe account settings, see:
* https://dashboard.stripe.com/test/apikeys
* https://dashboard.stripe.com/test/webhooks
2019-11-18 18:10:41 -05:00
### Set up your User Groups in Discourse
2020-02-05 20:45:29 -05:00
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.
2019-11-18 23:27:26 -05:00
2019-11-18 18:10:41 -05:00
## Enter your configuration details
2019-11-18 17:59:15 -05:00
2019-12-15 22:10:25 -05:00
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.
2019-11-18 19:52:09 -05:00
2019-11-18 23:21:12 -05:00
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.
2019-12-02 18:34:25 -05:00
If you take a look at your [Stripe Dashboard](https://dashboard.stripe.com), you'll see all those products and plans are listed. Discourse Subscriptions does not create them locally. They are created in Stripe.
2019-11-18 23:21:12 -05:00
2019-09-11 05:24:25 -04:00
## Testing
2019-09-11 23:40:18 -04:00
Test with these credit card numbers:
2020-01-14 02:46:48 -05:00
* 4111 1111 1111 1111 (no authentication required)
* 4000 0027 6000 3184 (authentication required)
For more test card numbers: https://stripe.com/docs/testing
2019-09-11 23:40:18 -04:00
2019-12-15 22:10:25 -05:00
Visit `/s` and enter a few test transactions.
2019-11-18 23:27:26 -05:00
2019-09-12 01:13:08 -04:00
## Credits
2020-02-05 20:45:29 -05:00
Many thanks to the Discourse team who sponsor this plugin! You guys rock. Also thanks to Chris Beach and Angus McLeod who helped on the previous version of this plugin. If you would like to contribute vis sponsorship to this project see: https://github.com/sponsors/rimian
2019-09-12 03:47:08 -04:00
2019-11-18 22:37:07 -05:00
## Screenshots
2019-11-18 22:40:07 -05:00
### Products Admin
2020-02-05 23:00:41 -05:00
![Admin Products](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/admin-products.png)
2019-11-18 22:40:07 -05:00
### Product Admin
2020-02-05 23:00:41 -05:00
![Admin Product](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/admin-product.png)
2019-11-18 22:40:07 -05:00
### Plan Admin
2020-02-05 23:00:41 -05:00
![Admin Plan](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/admin-plan.png)
2019-11-18 22:40:07 -05:00
### Subscription Admin
2020-02-05 23:00:41 -05:00
![Admin Subscriptions](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/admin-subscriptions.png)
2019-11-18 23:01:21 -05:00
### Subscription User
2020-02-05 23:00:41 -05:00
![Admin Subscriptions](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/user-subscriptions.png)
2019-12-17 03:49:08 -05:00
### Payments User
2020-02-05 23:00:41 -05:00
![Admin Subscriptions](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/user-payments.png)
2019-11-18 23:02:19 -05:00
### Subscribe
2020-02-05 23:00:41 -05:00
![Admin Subscriptions](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/subscribe.png)
2020-02-05 17:52:13 -05:00
### Settings
2020-02-05 23:00:41 -05:00
![Admin Settings](https://raw.githubusercontent.com/rimian/discourse-subscriptions/master/doc/settings.png)