From c0ddd251989b1cafc1f6e58c91216e1238dfdddf Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 28 Feb 2017 13:23:23 +1100 Subject: [PATCH] remove settings yaml config --- README.md | 17 +---------------- .../discourse_donations/charges_controller.rb | 2 ++ config/stripe.rb | 14 -------------- plugin.rb | 5 +---- 4 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 config/stripe.rb diff --git a/README.md b/README.md index 4924b6b..eb4615a 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,15 @@ Accept donations in Discourse! Integrates with [Stripe](https://stripe.com). ## Configuration -You can either set your environment vars in docker or save them in a yaml. - -In your `app.yml`: - -``` - STRIPE_SECRET_KEY: 'sk_test_key' - STRIPE_PUBLISHABLE_KEY: 'pk_test_key' -``` +Visit `/admin/plugins` and configure your private and public keys. ## TODO -* Remove hard coded key and use settings. * Add a plugin outlet for custom user fields. * Some tests * Handle fails from stripe * 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 To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-donations]` in the discourse root directory. diff --git a/app/controllers/discourse_donations/charges_controller.rb b/app/controllers/discourse_donations/charges_controller.rb index 0fe7688..4442d59 100644 --- a/app/controllers/discourse_donations/charges_controller.rb +++ b/app/controllers/discourse_donations/charges_controller.rb @@ -7,6 +7,8 @@ module DiscourseDonations skip_before_filter :verify_authenticity_token, only: [:create] def create + Stripe.api_key = SiteSetting.discourse_donations_secret_key + customer = Stripe::Customer.create( :email => current_user.email, :source => params[:stripeToken] diff --git a/config/stripe.rb b/config/stripe.rb deleted file mode 100644 index bee5482..0000000 --- a/config/stripe.rb +++ /dev/null @@ -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] diff --git a/plugin.rb b/plugin.rb index 1269421..3d15dc2 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,15 +1,12 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.5 +# version: 1.6.7 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins gem 'stripe', '2.0.1' 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 header_script = ''