mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-08 15:22:46 +00:00
Merge branch 'settings' into staging
This commit is contained in:
commit
cc7564af99
17
README.md
17
README.md
@ -6,30 +6,15 @@ Accept donations in Discourse! Integrates with [Stripe](https://stripe.com).
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
You can either set your environment vars in docker or save them in a yaml.
|
Visit `/admin/plugins` and configure your private and public keys.
|
||||||
|
|
||||||
In your `app.yml`:
|
|
||||||
|
|
||||||
```
|
|
||||||
STRIPE_SECRET_KEY: 'sk_test_key'
|
|
||||||
STRIPE_PUBLISHABLE_KEY: 'pk_test_key'
|
|
||||||
```
|
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
* Remove hard coded key and use settings.
|
|
||||||
* Add a plugin outlet for custom user fields.
|
* Add a plugin outlet for custom user fields.
|
||||||
* Some tests
|
* Some tests
|
||||||
* Handle fails from stripe
|
* Handle fails from stripe
|
||||||
* A button in the user's profile page.
|
* A button in the user's profile page.
|
||||||
|
|
||||||
**In your app.yml**
|
|
||||||
|
|
||||||
```
|
|
||||||
STRIPE_SECRET_KEY: 'my_secret_key'
|
|
||||||
STRIPE_PUBLISHABLE_KEY: 'my_publishable_key'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-donations]` in the discourse root directory.
|
To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-donations]` in the discourse root directory.
|
||||||
|
@ -7,6 +7,8 @@ module DiscourseDonations
|
|||||||
skip_before_filter :verify_authenticity_token, only: [:create]
|
skip_before_filter :verify_authenticity_token, only: [:create]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
Stripe.api_key = SiteSetting.discourse_donations_secret_key
|
||||||
|
|
||||||
customer = Stripe::Customer.create(
|
customer = Stripe::Customer.create(
|
||||||
:email => current_user.email,
|
:email => current_user.email,
|
||||||
:source => params[:stripeToken]
|
:source => params[:stripeToken]
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
if File.exist?('config/stripe.yml')
|
|
||||||
Rails.configuration.stripe = {
|
|
||||||
:publishable_key => Rails.application.config_for(:stripe)['publishable_key'],
|
|
||||||
:secret_key => Rails.application.config_for(:stripe)['secret_key']
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Rails.configuration.stripe = {
|
|
||||||
:publishable_key => ENV['STRIPE_PUBLISHABLE_KEY'],
|
|
||||||
:secret_key => ENV['STRIPE_SECRET_KEY']
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
Stripe.api_key = Rails.configuration.stripe[:secret_key]
|
|
@ -1,15 +1,12 @@
|
|||||||
# name: discourse-donations
|
# name: discourse-donations
|
||||||
# about: Integrating Discourse with Stripe for donations
|
# about: Integrating Discourse with Stripe for donations
|
||||||
# version: 1.6.5
|
# version: 1.6.7
|
||||||
# url: https://github.com/choiceaustralia/discourse-donations
|
# url: https://github.com/choiceaustralia/discourse-donations
|
||||||
# authors: Rimian Perkins
|
# authors: Rimian Perkins
|
||||||
|
|
||||||
gem 'stripe', '2.0.1'
|
gem 'stripe', '2.0.1'
|
||||||
|
|
||||||
load File.expand_path('../lib/discourse_donations/engine.rb', __FILE__)
|
load File.expand_path('../lib/discourse_donations/engine.rb', __FILE__)
|
||||||
load File.expand_path('../config/stripe.rb', __FILE__)
|
|
||||||
|
|
||||||
enabled_site_setting :discourse_donations_enabled
|
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
header_script = '<script src="https://js.stripe.com/v3/"></script>'
|
header_script = '<script src="https://js.stripe.com/v3/"></script>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user