ondrej
June 12, 2021, 8:34pm
4
Hey @filmore
As Craig said the Discourse subscription plugin is what you are looking for in your case. There is a new campaign feature which allows you to ask your community for help.
discourse:main
← discourse:campaigns
opened 05:02PM - 27 May 21 UTC
One of the main goals of this plugin is to make it easy for Discourse site owner… s to crowdsource funding of their communities. This PR adds a feature to build on top of that goal by making it extremely simple to run a support campaign for a site using Discourse Subscriptions.
## Features
<img width="1129" alt="image" src="https://user-images.githubusercontent.com/11862022/119864232-0c1b4e80-bee0-11eb-96f4-a95d5b6eb209.png">
To start, we've added the ability to turn on a campaign fundraising banner. The banner is configurable in a few ways:
1. By setting `discourse subscriptions campaign product` with a Stripe product id, clicking the Support button on the banner will take the user directly to the product to purchase.
2. The type of goal is configurable via `discourse subscriptions campaign type`. Currently we have `Subscribers` and `Amount Raised` as options available.
3. The goal amount is configurable via `discourse subscriptions campaign goal` This is a numerical value and is used to calculate the progress bar.
4. The avatars of a few of the most recent contributors can be displayed below the progress bar. It can be turned off by toggling `discourse subscriptions campaign show contributors`.
5. All text is customizable through the Admin > Customize > Text area.
Lastly the location can be configured to remain on the top (default), or as a sidebar on the topic list via the `discourse subscriptions campaign banner location` setting.
<img width="238" alt="image" src="https://user-images.githubusercontent.com/11862022/119865880-c6f81c00-bee1-11eb-8616-643196aec5e0.png">
---
<img width="323" alt="image" src="https://user-images.githubusercontent.com/11862022/119864095-e7bf7200-bedf-11eb-9771-b048fd992abf.png">
To make setting up a campaign as easy as possible, we've added an easy button! As soon as the Stripe public and private keys are added to the settings, an admin may click this button to automatically generate the following:
- A group titled supporters with a default user title and avatar flair (this can be adjusted after the fact)
- A Stripe product
- Six Stripe prices (3/mo, 5/mo, 10/mo, 25/mo, 50/yr, 100/yr)
Working with Stripe via the API can be fiddly, but adding this button removes most of the technical complexity and fiddlyness of the process.
## Technical Details
Most of this is pretty straight forward. We're storing the campaign status data in hidden site settings.
Two reasons for this:
1. A table would've been overkill
2. Querying the Stripe API every time a user hit the site would... not have been great.
Updating the site settings is facilitated by a `services/campaign.rb`. There are two Sidekiq jobs to help manage updating the campaign data -- one manual job that can be triggered from the Admin > Plugins > Subscriptions screen, and one that runs every 30 minutes. This follows a similar pattern from the Patreon plugin.
`services/campaign.rb` also handles the creation of the campaign models/objects when auto-creating a campaign.
The `campaign-banner.js` component uses a number of `@discourseComputed` properties to handle grabbing or checking the associated site settings with this feature. This could be refactored into a dedicated route returning a model, but I figured since we have access to the settings on the client already, this method would be simpler.
4 Likes