I’m new to building plugins for Discourse so I’m completely open to any critique or feedback on this.
I really wanted a premium section for a new community I recently launched. I’ve worked with Braintree in the past and figured it would give me the integration since I couldn’t find what I wanted. It ended up being built as a plugin so I figured I would share it here.
The set up steps can be found in the README of the GitHub repo here - Discourse Premium BT.
Ultimately, it syncs up with Braintree to create a paywall for a group. You can use the group to create a paid private category or grant badges for premium subscribers. And I’m sure there are other ways to use this that I can’t think of.
And since Ill be looking for ways to encourage people to share the site, there is an affiliate portion that can grant a discount from Braintree when a new user signs up using the current users custom link. This works by setting a cookie when the link is clicked and grants a free month of premium to the referrer when the new user confirms their email.
Here’s a look at the addition to the user preferences:
It is currently able to accept credit cards and PayPal.
Once the user subscribes it changes from “Subscribe” to “Update Payment” and “Cancel Subscription”. But all of the terminology is handled from a locale so you should be able to edit it in your admin settings.
There is also a banner that is displayed at the top of any topic that will help promote the premium section.
Any time something happens that will affect the payment or access to the group, a private message is sent. Right now, here are the messages that are sent:
- Subscription success
- Payment updated
- Subscription cancelled
- Free month expiration warning three days out
- Free month expired
- Free month granted
A few of these messages are triggered from background jobs. There are three of these:
- Free month expiration check every hour
- Free month expiration warning check every hour
- Subscription validation every six hours to ensure payment method is still valid
I’d be more than open to any feedback, PRs, or donations (see paypal button in repo) for this project.
Thanks and enjoy!
- [DONE] Clean up error messages passed to the user during subscription, payment updates, and cancellation