From 4634e37fe57fba5b3b6b3e953b5826b7bbf499d5 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 10:28:29 +1100 Subject: [PATCH 01/30] document test runner --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0ec5804..c0a4414 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,11 @@ STRIPE_PUBLISHABLE_KEY: 'my_publishable_key' ## Testing -To run the specs, install the plugin and run `bundle exec rake plugin:spec[discourse-payments]` in the discourse root directory. +To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-payments]` in the discourse root directory. -If you're using a zsh shell, then you probably get this error: `zsh: no matches found ...` and you'll need to escape the square brackets with backslashes. +To run qunit tests: `MODULE='Acceptance: Discourse Payments' rake qunit:test[20000]`. -Run the local js acceptance tests here: +**Note:** -http://localhost:3000/qunit?module=Acceptance%3A%20Discourse%20Payments +* [This fix](https://github.com/discourse/discourse/pull/4719) is required to run qunit test modules. +* If you're using a zsh shell, then you probably get this error: `zsh: no matches found ...` and you'll need to escape the square brackets with backslashes. From 7e54647cd0193d73875685ba4061eda2d5f2c215 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 12:12:02 +1100 Subject: [PATCH 02/30] update readme with new name yo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c0a4414..68d10b8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Discourse Payments +# Discourse Donations -[![Build Status](https://travis-ci.org/choiceaustralia/discourse-payments.svg?branch=master)](https://travis-ci.org/choiceaustralia/discourse-payments) +[![Build Status](https://travis-ci.org/choiceaustralia/discourse-donations.svg?branch=master)](https://travis-ci.org/choiceaustralia/discourse-donations) -Enables stripe payments from discourse. +Accept donations in Discourse! Integrates with [Stripe](https://stripe.com). ## Configuration From 88025395756f59a87d7d1fe5028ca390e54721e8 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 12:42:59 +1100 Subject: [PATCH 03/30] name space plugin and travis --- .travis.yml | 4 ++-- README.md | 2 +- plugin.rb | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2d2b29..8252c45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - git clone https://github.com/choiceaustralia/discourse-payments.git plugins/discourse-payments --depth=1 + - git clone https://github.com/choiceaustralia/discourse-donations.git plugins/discourse-donations --depth=1 before_script: - gem install bundler @@ -37,4 +37,4 @@ before_script: - bundle exec rake db:create db:migrate script: - - "bundle exec rake plugin:spec[discourse-payments] && bundle exec rake qunit:test['200000']" + - "bundle exec rake plugin:spec[discourse-donations] && bundle exec rake qunit:test['200000']" diff --git a/README.md b/README.md index 68d10b8..bc3d257 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ STRIPE_PUBLISHABLE_KEY: 'my_publishable_key' ## Testing -To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-payments]` 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. To run qunit tests: `MODULE='Acceptance: Discourse Payments' rake qunit:test[20000]`. diff --git a/plugin.rb b/plugin.rb index df456df..1386dab 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ -# name: discourse-payments -# about: Integrating Discourse with Stripe -# version: 1.5.0 -# url: https://github.com/choiceaustralia/discourse-payments +# name: discourse-donations +# about: Integrating Discourse with Stripe for donations +# version: 1.6.0 +# url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins gem 'stripe', '2.0.1' @@ -13,13 +13,15 @@ after_initialize do header_script = '' discourse_payments_customization = SiteCustomization.find_or_create_by({ - name: 'Discourse Payments Header', + name: 'Discourse Donations Header', header: header_script, mobile_header: header_script, enabled: true, user_id: -1 }) + # Delete the old header (1.5.0) + SiteCustomization.where(name: 'Discourse Payments Header').delete_all SiteCustomization.where(name: discourse_payments_customization.name).where.not(id: discourse_payments_customization.id).delete_all end From 23850afeb1bfe9be71a026709292b288f62fb2d0 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 12:51:26 +1100 Subject: [PATCH 04/30] rename js test --- README.md | 2 +- test/javascripts/acceptance/discourse-payments-test.es6 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc3d257..73d26c3 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ STRIPE_PUBLISHABLE_KEY: 'my_publishable_key' To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-donations]` in the discourse root directory. -To run qunit tests: `MODULE='Acceptance: Discourse Payments' rake qunit:test[20000]`. +To run qunit tests: `MODULE='Acceptance: Discourse Donations' rake qunit:test[20000]`. **Note:** diff --git a/test/javascripts/acceptance/discourse-payments-test.es6 b/test/javascripts/acceptance/discourse-payments-test.es6 index a8beabb..4ae14c6 100644 --- a/test/javascripts/acceptance/discourse-payments-test.es6 +++ b/test/javascripts/acceptance/discourse-payments-test.es6 @@ -1,5 +1,5 @@ import { acceptance } from 'helpers/qunit-helpers'; -acceptance('Discourse Payments', { loggedIn: true }); +acceptance('Discourse Donations', { loggedIn: true }); test('Payments Link Exists', () => { visit('/users/eviltrout'); From 97e4497cc83336dfaa0d8c7136675b195cfc5fc5 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:09:27 +1100 Subject: [PATCH 05/30] acceptance test link --- .../templates/connectors/user-profile-primary/link.hbs | 4 ++-- ...scourse-payments-test.es6 => discourse-donations-test.es6} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename test/javascripts/acceptance/{discourse-payments-test.es6 => discourse-donations-test.es6} (59%) diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs index 6c4e8b2..8dc3f75 100644 --- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs +++ b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs @@ -1,4 +1,4 @@ -
- Payments page +
+ Donate
diff --git a/test/javascripts/acceptance/discourse-payments-test.es6 b/test/javascripts/acceptance/discourse-donations-test.es6 similarity index 59% rename from test/javascripts/acceptance/discourse-payments-test.es6 rename to test/javascripts/acceptance/discourse-donations-test.es6 index 4ae14c6..17ed0e4 100644 --- a/test/javascripts/acceptance/discourse-payments-test.es6 +++ b/test/javascripts/acceptance/discourse-donations-test.es6 @@ -1,10 +1,10 @@ import { acceptance } from 'helpers/qunit-helpers'; acceptance('Discourse Donations', { loggedIn: true }); -test('Payments Link Exists', () => { +test('Donations Link Exists', () => { visit('/users/eviltrout'); andThen(() => { - ok(exists('.discourse-payments > a'), 'Link exists on profile page'); + ok(exists('.discourse-donations > a'), 'Link exists on profile page'); }); }); From 7d42f286665b67cda21fd7815c4f62ad732225f4 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:12:25 +1100 Subject: [PATCH 06/30] readme: bundle exec tests --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73d26c3..4924b6b 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ STRIPE_PUBLISHABLE_KEY: 'my_publishable_key' To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-donations]` in the discourse root directory. -To run qunit tests: `MODULE='Acceptance: Discourse Donations' rake qunit:test[20000]`. +To run qunit tests: `MODULE='Acceptance: Discourse Donations' bundle exec rake qunit:test[20000]`. **Note:** From 3a428d17f0d6b149b200265b20343fe6a0aaa760 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:23:11 +1100 Subject: [PATCH 07/30] name space the rails things --- .../charges_controller.rb | 2 +- .../payments_controller.rb | 2 +- .../application_helper.rb | 2 +- config/routes.rb | 2 +- lib/discourse_donations/engine.rb | 6 ++++++ lib/discourse_payments/engine.rb | 6 ------ plugin.rb | 4 ++-- .../charges_controller_spec.rb | 4 ++-- .../payments_controller_spec.rb | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) rename app/controllers/{discourse_payments => discourse_donations}/charges_controller.rb (95%) rename app/controllers/{discourse_payments => discourse_donations}/payments_controller.rb (85%) rename app/helpers/{discourse_payments => discourse_donations}/application_helper.rb (59%) create mode 100644 lib/discourse_donations/engine.rb delete mode 100644 lib/discourse_payments/engine.rb rename spec/controllers/{discourse_payments => discourse_donations}/charges_controller_spec.rb (75%) rename spec/controllers/{discourse_payments => discourse_donations}/payments_controller_spec.rb (55%) diff --git a/app/controllers/discourse_payments/charges_controller.rb b/app/controllers/discourse_donations/charges_controller.rb similarity index 95% rename from app/controllers/discourse_payments/charges_controller.rb rename to app/controllers/discourse_donations/charges_controller.rb index 4bf4d85..0fe7688 100644 --- a/app/controllers/discourse_payments/charges_controller.rb +++ b/app/controllers/discourse_donations/charges_controller.rb @@ -1,6 +1,6 @@ require_dependency 'discourse' -module DiscoursePayments +module DiscourseDonations class ChargesController < ActionController::Base include CurrentUser diff --git a/app/controllers/discourse_payments/payments_controller.rb b/app/controllers/discourse_donations/payments_controller.rb similarity index 85% rename from app/controllers/discourse_payments/payments_controller.rb rename to app/controllers/discourse_donations/payments_controller.rb index 9dd2621..e4a6c27 100644 --- a/app/controllers/discourse_payments/payments_controller.rb +++ b/app/controllers/discourse_donations/payments_controller.rb @@ -1,4 +1,4 @@ -module DiscoursePayments +module DiscourseDonations class PaymentsController < ApplicationController def index render json: {} diff --git a/app/helpers/discourse_payments/application_helper.rb b/app/helpers/discourse_donations/application_helper.rb similarity index 59% rename from app/helpers/discourse_payments/application_helper.rb rename to app/helpers/discourse_donations/application_helper.rb index 012d848..9009142 100644 --- a/app/helpers/discourse_payments/application_helper.rb +++ b/app/helpers/discourse_donations/application_helper.rb @@ -1,5 +1,5 @@ -module DiscoursePayments +module DiscourseDonations module ApplicationHelper end end diff --git a/config/routes.rb b/config/routes.rb index cf8481a..519853a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -DiscoursePayments::Engine.routes.draw do +DiscourseDonations::Engine.routes.draw do resources :charges, only: [:create] get 'users/:username/payments' => 'payments#show' end diff --git a/lib/discourse_donations/engine.rb b/lib/discourse_donations/engine.rb new file mode 100644 index 0000000..d92e065 --- /dev/null +++ b/lib/discourse_donations/engine.rb @@ -0,0 +1,6 @@ +module ::DiscourseDonations + class Engine < ::Rails::Engine + engine_name 'discourse-donations' + isolate_namespace DiscourseDonations + end +end diff --git a/lib/discourse_payments/engine.rb b/lib/discourse_payments/engine.rb deleted file mode 100644 index 2770737..0000000 --- a/lib/discourse_payments/engine.rb +++ /dev/null @@ -1,6 +0,0 @@ -module ::DiscoursePayments - class Engine < ::Rails::Engine - engine_name 'discourse-payments' - isolate_namespace DiscoursePayments - end -end diff --git a/plugin.rb b/plugin.rb index 1386dab..a3282f0 100644 --- a/plugin.rb +++ b/plugin.rb @@ -6,7 +6,7 @@ gem 'stripe', '2.0.1' -load File.expand_path('../lib/discourse_payments/engine.rb', __FILE__) +load File.expand_path('../lib/discourse_donations/engine.rb', __FILE__) load File.expand_path('../config/stripe.rb', __FILE__) after_initialize do @@ -26,5 +26,5 @@ after_initialize do end Discourse::Application.routes.prepend do - mount ::DiscoursePayments::Engine, at: '/' + mount ::DiscourseDonations::Engine, at: '/' end diff --git a/spec/controllers/discourse_payments/charges_controller_spec.rb b/spec/controllers/discourse_donations/charges_controller_spec.rb similarity index 75% rename from spec/controllers/discourse_payments/charges_controller_spec.rb rename to spec/controllers/discourse_donations/charges_controller_spec.rb index ca9b7fa..eef34d2 100644 --- a/spec/controllers/discourse_payments/charges_controller_spec.rb +++ b/spec/controllers/discourse_donations/charges_controller_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -module DiscoursePayments +module DiscourseDonations RSpec.describe ChargesController, type: :controller do - routes { DiscoursePayments::Engine.routes } + routes { DiscourseDonations::Engine.routes } # it 'responds with ok' do skip 'need to get fixtures' diff --git a/spec/controllers/discourse_payments/payments_controller_spec.rb b/spec/controllers/discourse_donations/payments_controller_spec.rb similarity index 55% rename from spec/controllers/discourse_payments/payments_controller_spec.rb rename to spec/controllers/discourse_donations/payments_controller_spec.rb index 6a369dc..0922802 100644 --- a/spec/controllers/discourse_payments/payments_controller_spec.rb +++ b/spec/controllers/discourse_donations/payments_controller_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -module DiscoursePayments +module DiscourseDonations RSpec.describe PaymentsController, type: :controller do - routes { DiscoursePayments::Engine.routes } + routes { DiscourseDonations::Engine.routes } end end From 669aba65491c7e8658b4ddb71b5a7a1303d2c5ee Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:28:11 +1100 Subject: [PATCH 08/30] link instead of check out master --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d2d2b29..22fa249 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - git clone https://github.com/choiceaustralia/discourse-payments.git plugins/discourse-payments --depth=1 + - ln -s ../discourse-payments plugins/discourse-payments before_script: - gem install bundler From bf6a1be87baff047a1dc334f40003a663931f50e Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:29:35 +1100 Subject: [PATCH 09/30] update name --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22fa249..47b887e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - ln -s ../discourse-payments plugins/discourse-payments + - ln -s ../discourse-donations plugins/discourse-donations before_script: - gem install bundler From 0429c15a05b201a9bc749c6141d21cbd29fe5eb6 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:35:18 +1100 Subject: [PATCH 10/30] folder name yo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 47b887e..dd571f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - ln -s ../discourse-donations plugins/discourse-donations + - ln -s ../discourse-donations plugins/discourse-payments before_script: - gem install bundler From 1a0827b564f46c4b2b3ca906795f3902b81a98fe Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:41:36 +1100 Subject: [PATCH 11/30] use local version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8252c45..07ef022 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - git clone https://github.com/choiceaustralia/discourse-donations.git plugins/discourse-donations --depth=1 + - ln -s ../discourse-donations plugins/discourse-donations before_script: - gem install bundler From 8b016504d9a4108ac20ea4a985de2c2bababc21c Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:46:33 +1100 Subject: [PATCH 12/30] show folders --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 07ef022..c6a8655 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,8 @@ before_install: install: - touch config/stripe.yml - ln -s ../discourse-donations plugins/discourse-donations + - ls -l plugins + - ls -l plugins/discourse-donations before_script: - gem install bundler From ce6bf882e646089bb11b16c9ea6fe60edfe22630 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:50:09 +1100 Subject: [PATCH 13/30] fix ln --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6a8655..29e82c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: dist: trusty -cache: bundler +cache: bundler --path discourse/vendor addons: postgresql: 9.5 @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - ln -s ../discourse-donations plugins/discourse-donations + - ln -s ../discourse-donations plugins - ls -l plugins - ls -l plugins/discourse-donations From 210da8ca7ff5069439d21c70a51a1c8df04685e7 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:52:56 +1100 Subject: [PATCH 14/30] finx ls --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dd571f9..e74d299 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - ln -s ../discourse-donations plugins/discourse-payments + - ln -s ../discourse-donations plugins before_script: - gem install bundler From 1f3347a8e1a8c97d339396e7690bdf71973ce205 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 13:58:50 +1100 Subject: [PATCH 15/30] list dirs --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e74d299..05d149d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,8 @@ before_install: install: - touch config/stripe.yml + - ls -l + - ls -l ../ - ln -s ../discourse-donations plugins before_script: From 427ac013af8137abe394472f7ff4aa4e3b1127dd Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 14:04:04 +1100 Subject: [PATCH 16/30] clone it --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05d149d..1356583 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,9 +29,7 @@ before_install: install: - touch config/stripe.yml - - ls -l - - ls -l ../ - - ln -s ../discourse-donations plugins + - git clone $TRAVIS_BUILD_DIR plugins/discourse-payments --depth 50 before_script: - gem install bundler From 0c1646572e7a409c2ffca1cfedfa717304273837 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 14:09:21 +1100 Subject: [PATCH 17/30] ensure branch and set cache to discourse/vendor --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1356583..b7a17ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: dist: trusty -cache: bundler +cache: bundler --path $TRAVIS_BUILD_DIR/discourse/vendor addons: postgresql: 9.5 @@ -29,7 +29,7 @@ before_install: install: - touch config/stripe.yml - - git clone $TRAVIS_BUILD_DIR plugins/discourse-payments --depth 50 + - git clone $TRAVIS_BUILD_DIR plugins/discourse-payments --depth 50 --branch $TRAVIS_BRANCH before_script: - gem install bundler From 3c1b351d3b9a57daf3ebc7b64117c3629199760b Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 14:18:59 +1100 Subject: [PATCH 18/30] bump --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index a3282f0..f1f67a2 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.0 +# version: 1.6.1 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins From 8769306a861b79283a6477b4779298ab57a757b2 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 11:42:48 +1100 Subject: [PATCH 19/30] German translation --- config/locales/client.de.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index 48de9f9..e59716b 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -1,8 +1,8 @@ en: js: discourse_payments: - title: Donate - amount: Amount - card: Credit or debit card - success: Payment Successful! - submit: Make Payment + title: Spenden + amount: Betrag + card: Kreditkarte oder Bankkarte + success: Bezahlung erfolgreich ! + submit: Spende bezahlen From 2f7a67629ce9f493f72deeb14a0d9c5929e4f023 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 11:49:01 +1100 Subject: [PATCH 20/30] custom header name space and remove delete old --- plugin.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugin.rb b/plugin.rb index f1f67a2..7cb7de4 100644 --- a/plugin.rb +++ b/plugin.rb @@ -12,7 +12,7 @@ load File.expand_path('../config/stripe.rb', __FILE__) after_initialize do header_script = '' - discourse_payments_customization = SiteCustomization.find_or_create_by({ + discourse_donations_customization = SiteCustomization.find_or_create_by({ name: 'Discourse Donations Header', header: header_script, mobile_header: header_script, @@ -20,9 +20,7 @@ after_initialize do user_id: -1 }) - # Delete the old header (1.5.0) - SiteCustomization.where(name: 'Discourse Payments Header').delete_all - SiteCustomization.where(name: discourse_payments_customization.name).where.not(id: discourse_payments_customization.id).delete_all + SiteCustomization.where(name: discourse_donations_customization.name).where.not(id: discourse_donations_customization.id).delete_all end Discourse::Application.routes.prepend do From a77cf00504922e6d6f2b82fff0f064d2b4243165 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 11:52:34 +1100 Subject: [PATCH 21/30] update name space in locales --- .../discourse/components/stripe-card.js.es6 | 2 +- .../discourse/templates/components/stripe-card.hbs | 10 +++++----- .../javascripts/discourse/templates/user/payments.hbs | 4 ++-- config/locales/client.de.yml | 2 +- config/locales/client.en.yml | 2 +- plugin.rb | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/assets/javascripts/discourse/components/stripe-card.js.es6 b/assets/javascripts/discourse/components/stripe-card.js.es6 index b8f5a6d..ac25c07 100644 --- a/assets/javascripts/discourse/components/stripe-card.js.es6 +++ b/assets/javascripts/discourse/components/stripe-card.js.es6 @@ -2,7 +2,7 @@ import { ajax } from 'discourse/lib/ajax'; export default Ember.Component.extend({ result: null, - paymentAmounts: [5, 10], + donateAmounts: [5, 10], amount: null, stripe: Stripe('pk_test_b8RmhzlL8QPizJRqOrKF3JEV'), diff --git a/assets/javascripts/discourse/templates/components/stripe-card.hbs b/assets/javascripts/discourse/templates/components/stripe-card.hbs index 15b111f..5983439 100644 --- a/assets/javascripts/discourse/templates/components/stripe-card.hbs +++ b/assets/javascripts/discourse/templates/components/stripe-card.hbs @@ -1,22 +1,22 @@
- +
- {{combo-box valueAttribute="value" content=paymentAmounts value=amount}} + {{combo-box valueAttribute="value" content=donateAmounts value=amount}}
- +
- + {{#if result}} - {{i18n 'discourse_payments.success'}} + {{i18n 'discourse_donations.success'}} {{/if}}
diff --git a/assets/javascripts/discourse/templates/user/payments.hbs b/assets/javascripts/discourse/templates/user/payments.hbs index bca741e..229f783 100644 --- a/assets/javascripts/discourse/templates/user/payments.hbs +++ b/assets/javascripts/discourse/templates/user/payments.hbs @@ -1,9 +1,9 @@ -{{#d-section pageClass="user-payments" class="user-content user-payments"}} +{{#d-section pageClass="user-donations" class="user-content user-donations"}}
diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index e59716b..79ea61b 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -1,6 +1,6 @@ en: js: - discourse_payments: + discourse_donations: title: Spenden amount: Betrag card: Kreditkarte oder Bankkarte diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 48de9f9..23708ec 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1,6 +1,6 @@ en: js: - discourse_payments: + discourse_donations: title: Donate amount: Amount card: Credit or debit card diff --git a/plugin.rb b/plugin.rb index 7cb7de4..8869198 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.1 +# version: 1.6.2 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins From 65317324f28abf5ec9441daa9c49013b318e50ef Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 12:07:21 +1100 Subject: [PATCH 22/30] only show the link when the plugin is enabled --- .../templates/connectors/user-profile-primary/link.hbs | 9 +++++---- config/locales/server.en.yml | 3 +++ config/settings.yml | 4 ++++ plugin.rb | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 config/locales/server.en.yml create mode 100644 config/settings.yml diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs index 8dc3f75..6fb4ef1 100644 --- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs +++ b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs @@ -1,4 +1,5 @@ - -
- Donate -
+{{#if siteSettings.discourse_donations_enabled}} +
+ Donate +
+{{/if}} diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml new file mode 100644 index 0000000..4450eb9 --- /dev/null +++ b/config/locales/server.en.yml @@ -0,0 +1,3 @@ +en: + site_settings: + discourse_donations_enabled: "Enable the discourse donations plugin." diff --git a/config/settings.yml b/config/settings.yml new file mode 100644 index 0000000..b66dd35 --- /dev/null +++ b/config/settings.yml @@ -0,0 +1,4 @@ +plugins: + discourse_donations_enabled: + default: true + client: true diff --git a/plugin.rb b/plugin.rb index 8869198..c037d42 100644 --- a/plugin.rb +++ b/plugin.rb @@ -9,6 +9,8 @@ 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 = '' From a84de2c87660b9b989e190bd27aa276fdc470cd3 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 13:45:26 +1100 Subject: [PATCH 23/30] settings for public and private key --- assets/javascripts/discourse/templates/user/payments.hbs | 3 +++ config/locales/client.de.yml | 2 ++ config/locales/client.en.yml | 2 ++ config/settings.yml | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/assets/javascripts/discourse/templates/user/payments.hbs b/assets/javascripts/discourse/templates/user/payments.hbs index 229f783..582ce4a 100644 --- a/assets/javascripts/discourse/templates/user/payments.hbs +++ b/assets/javascripts/discourse/templates/user/payments.hbs @@ -1,3 +1,6 @@ + +{{siteSettings.discourse_donations_secret_key}} + {{#d-section pageClass="user-donations" class="user-content user-donations"}}
diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index 79ea61b..513e574 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -6,3 +6,5 @@ en: card: Kreditkarte oder Bankkarte success: Bezahlung erfolgreich ! submit: Spende bezahlen + secret_key: Secret Key + public_key: Public Key diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 23708ec..8df9394 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -6,3 +6,5 @@ en: card: Credit or debit card success: Payment Successful! submit: Make Payment + secret_key: Secret Key + public_key: Public Key diff --git a/config/settings.yml b/config/settings.yml index b66dd35..3734f51 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,3 +2,9 @@ plugins: discourse_donations_enabled: default: true client: true + discourse_donations_secret_key: + type: text + client: true + discourse_donations_public_key: + type: text + client: true From 19a7956f43b4c881ce2d6de5307d46ce5dea36bd Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 14:22:52 +1100 Subject: [PATCH 24/30] load the public key from settings --- assets/javascripts/discourse/components/stripe-card.js.es6 | 5 ++++- config/settings.yml | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/components/stripe-card.js.es6 b/assets/javascripts/discourse/components/stripe-card.js.es6 index ac25c07..a672eb5 100644 --- a/assets/javascripts/discourse/components/stripe-card.js.es6 +++ b/assets/javascripts/discourse/components/stripe-card.js.es6 @@ -4,7 +4,10 @@ export default Ember.Component.extend({ result: null, donateAmounts: [5, 10], amount: null, - stripe: Stripe('pk_test_b8RmhzlL8QPizJRqOrKF3JEV'), + + stripe: function() { + return Stripe(Discourse.discourse_donations_public_key); + }.property('stripe'), card: function() { var elements = this.get('stripe').elements(); diff --git a/config/settings.yml b/config/settings.yml index 3734f51..a4b5aa0 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -3,8 +3,6 @@ plugins: default: true client: true discourse_donations_secret_key: - type: text - client: true + client: false discourse_donations_public_key: - type: text client: true From 5c33b0f85ba6a46d7d10cb0060d4a789b11941a3 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 14:23:18 +1100 Subject: [PATCH 25/30] bump with settings fix --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index c037d42..97a27f9 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.2 +# version: 1.6.3 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins From b6a4d5dc8e39247edb562ba2c751cf44bb1c72cf Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 27 Feb 2017 14:26:50 +1100 Subject: [PATCH 26/30] whoops forgot test code --- assets/javascripts/discourse/templates/user/payments.hbs | 2 -- plugin.rb | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/assets/javascripts/discourse/templates/user/payments.hbs b/assets/javascripts/discourse/templates/user/payments.hbs index 582ce4a..ce01d90 100644 --- a/assets/javascripts/discourse/templates/user/payments.hbs +++ b/assets/javascripts/discourse/templates/user/payments.hbs @@ -1,6 +1,4 @@ -{{siteSettings.discourse_donations_secret_key}} - {{#d-section pageClass="user-donations" class="user-content user-donations"}}
diff --git a/plugin.rb b/plugin.rb index 97a27f9..93de9ce 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.3 +# version: 1.6.4 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins From 10e63f2a4c1777ec72575c6a4f6c7576c88a54b5 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 28 Feb 2017 12:39:07 +1100 Subject: [PATCH 27/30] fix i18n and import site settings --- .../discourse/components/stripe-card.js.es6 | 12 ++++++++---- config/locales/client.de.yml | 2 -- config/locales/client.en.yml | 2 -- config/locales/server.en.yml | 4 +++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/assets/javascripts/discourse/components/stripe-card.js.es6 b/assets/javascripts/discourse/components/stripe-card.js.es6 index a672eb5..4514e2e 100644 --- a/assets/javascripts/discourse/components/stripe-card.js.es6 +++ b/assets/javascripts/discourse/components/stripe-card.js.es6 @@ -1,13 +1,17 @@ import { ajax } from 'discourse/lib/ajax'; +import { getRegister } from 'discourse-common/lib/get-owner'; export default Ember.Component.extend({ + donateAmounts: [1, 5, 10, 25], result: null, - donateAmounts: [5, 10], amount: null, + stripe: null, - stripe: function() { - return Stripe(Discourse.discourse_donations_public_key); - }.property('stripe'), + init() { + this._super(); + var public_key = getRegister(this).lookup('site-settings:main').discourse_donations_public_key + this.set('stripe', Stripe(public_key)); + }, card: function() { var elements = this.get('stripe').elements(); diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index 513e574..79ea61b 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -6,5 +6,3 @@ en: card: Kreditkarte oder Bankkarte success: Bezahlung erfolgreich ! submit: Spende bezahlen - secret_key: Secret Key - public_key: Public Key diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 8df9394..23708ec 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -6,5 +6,3 @@ en: card: Credit or debit card success: Payment Successful! submit: Make Payment - secret_key: Secret Key - public_key: Public Key diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 4450eb9..cc64944 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,3 +1,5 @@ en: site_settings: - discourse_donations_enabled: "Enable the discourse donations plugin." + discourse_donations_enabled: Enable the discourse donations plugin. + discourse_donations_secret_key: Stripe Secret Key + discourse_donations_public_key: Stripe Public Key From a3d536aa05c094debe13138ca8c45f2cfeea8a48 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 28 Feb 2017 12:40:09 +1100 Subject: [PATCH 28/30] bumpus --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 93de9ce..1269421 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.4 +# version: 1.6.5 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins From c0ddd251989b1cafc1f6e58c91216e1238dfdddf Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 28 Feb 2017 13:23:23 +1100 Subject: [PATCH 29/30] 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 = '' From f0228b9d5a6a38d73ec9636a6a69a7027ea2685c Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 28 Feb 2017 13:36:41 +1100 Subject: [PATCH 30/30] enable settings --- plugin.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 3d15dc2..bb5c5ce 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.7 +# version: 1.6.8 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins @@ -8,6 +8,8 @@ gem 'stripe', '2.0.1' load File.expand_path('../lib/discourse_donations/engine.rb', __FILE__) +enabled_site_setting :discourse_donations_enabled + after_initialize do header_script = ''