stripe_event 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.travis.yml +16 -0
- data/Appraisals +11 -0
- data/CHANGELOG.md +42 -0
- data/Gemfile +2 -0
- data/LICENSE.md +3 -1
- data/README.md +8 -6
- data/Rakefile +12 -1
- data/app/controllers/stripe_event/webhook_controller.rb +1 -2
- data/config/routes.rb +1 -1
- data/dashboard-webhook.png +0 -0
- data/gemfiles/rails3.1.gemfile +7 -0
- data/gemfiles/rails3.1.gemfile.lock +122 -0
- data/gemfiles/rails3.2.gemfile +7 -0
- data/gemfiles/rails3.2.gemfile.lock +122 -0
- data/gemfiles/rails_master.gemfile +7 -0
- data/gemfiles/rails_master.gemfile.lock +126 -0
- data/lib/stripe_event.rb +23 -14
- data/lib/stripe_event/version.rb +1 -1
- data/spec/controllers/webhook_controller_spec.rb +28 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +64 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +40 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +16 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/stripe.rb +1 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/lib/stripe_event_spec.rb +45 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/active_support_helper.rb +15 -0
- data/spec/support/core_ext.rb +4 -0
- data/spec/support/fixture_helper.rb +10 -0
- data/spec/support/fixtures/evt_charge_succeeded.json +46 -0
- data/spec/support/fixtures/evt_invalid_id.json +7 -0
- data/stripe_event.gemspec +26 -0
- metadata +125 -12
- data/lib/stripe_event/publisher.rb +0 -12
- data/lib/stripe_event/subscriber.rb +0 -26
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- rbx-19mode
|
6
|
+
gemfile:
|
7
|
+
- gemfiles/rails3.1.gemfile
|
8
|
+
- gemfiles/rails3.2.gemfile
|
9
|
+
- gemfiles/rails_master.gemfile
|
10
|
+
matrix:
|
11
|
+
exclude:
|
12
|
+
- rvm: 1.9.2
|
13
|
+
gemfile: gemfiles/rails_master.gemfile
|
14
|
+
notifications:
|
15
|
+
email:
|
16
|
+
- daniel.r.whalen@gmail.com
|
data/Appraisals
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
### 0.6.0 (March 18, 2013)
|
2
|
+
* Rails 4 compatibility. Thank you to Ben Ubois for reporting the [issue](https://github.com/integrallis/stripe_event/issues/13) and to Matt Goldman for the [pull request](https://github.com/integrallis/stripe_event/pull/14).
|
3
|
+
* Run specs against different Rails versions
|
4
|
+
* Refactor internal usage of AS::Notifications
|
5
|
+
* Remove jruby-openssl as platform conditional dependency
|
6
|
+
|
7
|
+
### 0.5.0 (December 16, 2012)
|
8
|
+
* Remove `Gemfile.lock` from version control
|
9
|
+
* Internal event type list is now a set
|
10
|
+
* Update event type list
|
11
|
+
* Various internal refactorings
|
12
|
+
* More readable tests
|
13
|
+
|
14
|
+
### 0.4.0 (September 24, 2012)
|
15
|
+
* Add configuration for custom event retrieval. Thanks to Dan Hodos for the [pull request](https://github.com/integrallis/stripe_event/pull/6).
|
16
|
+
* Move module methods only used in tests into a test helper.
|
17
|
+
* Various internal refactorings and additional tests.
|
18
|
+
* Error classes will inherit from a base error class now.
|
19
|
+
|
20
|
+
### 0.3.1 (August 14, 2012)
|
21
|
+
* Fix controller inheritance issue. Thanks to Christopher Baran for [reporting the bug](https://github.com/integrallis/stripe_event/issues/1), and to Robert Bousquet for [fixing it](https://github.com/integrallis/stripe_event/pull/3).
|
22
|
+
* Deprecate registration method. Use 'setup' instead.
|
23
|
+
|
24
|
+
### 0.3.0 (July 16, 2012)
|
25
|
+
* Add registration method for conveniently adding many subscribers
|
26
|
+
* Depend on jruby-openssl when running on jruby
|
27
|
+
* Remove unneeded rake dependency
|
28
|
+
* Remove configure method
|
29
|
+
|
30
|
+
### 0.2.0 (July 12, 2012)
|
31
|
+
* Register a subscriber to one/many/all events
|
32
|
+
* Remove sqlite3 development dependency
|
33
|
+
* Setup travis-ci for repo
|
34
|
+
* Hard code a placeholder api key in dummy app. Fixes failing tests when env var not defined.
|
35
|
+
|
36
|
+
### 0.1.1 (July 4, 2012)
|
37
|
+
* Improve README
|
38
|
+
* Specify development dependency versions
|
39
|
+
* Fix controller test which was passing incorrectly
|
40
|
+
|
41
|
+
### 0.1.0 (June 24, 2012)
|
42
|
+
* Initial release
|
data/Gemfile
ADDED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
[](http://travis-ci.org/integrallis/stripe_event)
|
1
|
+
# stripe_event [](http://travis-ci.org/integrallis/stripe_event) [](https://gemnasium.com/integrallis/stripe_event)
|
4
2
|
|
5
3
|
stripe_event is built on the [ActiveSupport::Notifications API](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html). Incoming webhook requests are authenticated by retrieving the [event object](https://stripe.com/docs/api?lang=ruby#event_object) from Stripe[[1]](https://answers.stripe.com/questions/what-is-the-recommended-way-to-authenticate-a-webhook-callback). Define subscriber blocks to handle one, many, or all event types.
|
6
4
|
|
@@ -45,7 +43,7 @@ end
|
|
45
43
|
If you have built an application that has multiple Stripe accounts--say, each of your customers has their own--you may want to define your own way of retrieving events from Stripe (e.g. perhaps you want to use the [user_id parameter](https://stripe.com/docs/apps/getting-started#webhooks) from the top level to detect the customer for the event, then grab their specific API key). You can do this:
|
46
44
|
|
47
45
|
```ruby
|
48
|
-
StripeEvent.event_retriever =
|
46
|
+
StripeEvent.event_retriever = lambda do |params|
|
49
47
|
secret_key = Account.find_by_stripe_user_id(params[:user_id]).secret_key
|
50
48
|
Stripe::Event.retrieve(params[:id], secret_key)
|
51
49
|
end
|
@@ -54,12 +52,12 @@ end
|
|
54
52
|
During development it may be useful to skip retrieving the event from Stripe, and deal with the params hash directly. Just remember that the data has not been authenticated.
|
55
53
|
|
56
54
|
```ruby
|
57
|
-
StripeEvent.event_retriever =
|
55
|
+
StripeEvent.event_retriever = lambda { |params| params }
|
58
56
|
```
|
59
57
|
|
60
58
|
### Register webhook url with Stripe
|
61
59
|
|
62
|
-

|
63
61
|
|
64
62
|
### Examples
|
65
63
|
|
@@ -68,3 +66,7 @@ The [RailsApps](https://github.com/RailsApps) project by Daniel Kehoe has releas
|
|
68
66
|
### Note: 'Test Webhooks' Button on Stripe Dashboard
|
69
67
|
|
70
68
|
This button sends an example event to your webhook urls, including an `id` of `evt_00000000000000`. To confirm that Stripe sent the webhook, stripe_event attempts to retrieve the event details from Stripe using the given `id`. In this case the event does not exist and stripe_event responds with `401 Unauthorized`. Instead of using the 'Test Webhooks' button, trigger webhooks by using the Stripe Dashboard to create test payments, customers, etc.
|
69
|
+
|
70
|
+
### License
|
71
|
+
|
72
|
+
[MIT License](https://github.com/integrallis/stripe_event/blob/master/LICENSE.md). Copyright 2012-2013 Integrallis Software.
|
data/Rakefile
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'bundler/gem_tasks'
|
1
4
|
require 'rspec/core/rake_task'
|
2
5
|
|
3
6
|
RSpec::Core::RakeTask.new(:spec)
|
4
|
-
|
7
|
+
|
8
|
+
if ENV['CI']
|
9
|
+
task :default => :spec
|
10
|
+
else
|
11
|
+
require 'appraisal'
|
12
|
+
task :default do
|
13
|
+
system('bundle exec rake appraisal spec')
|
14
|
+
end
|
15
|
+
end
|
data/config/routes.rb
CHANGED
Binary file
|
@@ -0,0 +1,122 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/dwhalen/Dropbox/stripe_event
|
3
|
+
specs:
|
4
|
+
stripe_event (0.6.0)
|
5
|
+
rails (>= 3.1)
|
6
|
+
stripe (~> 1.6)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.12)
|
12
|
+
actionpack (= 3.2.12)
|
13
|
+
mail (~> 2.4.4)
|
14
|
+
actionpack (3.2.12)
|
15
|
+
activemodel (= 3.2.12)
|
16
|
+
activesupport (= 3.2.12)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.4)
|
20
|
+
rack (~> 1.4.5)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.2.1)
|
24
|
+
activemodel (3.2.12)
|
25
|
+
activesupport (= 3.2.12)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.12)
|
28
|
+
activemodel (= 3.2.12)
|
29
|
+
activesupport (= 3.2.12)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.12)
|
33
|
+
activemodel (= 3.2.12)
|
34
|
+
activesupport (= 3.2.12)
|
35
|
+
activesupport (3.2.12)
|
36
|
+
i18n (~> 0.6)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
addressable (2.3.3)
|
39
|
+
appraisal (0.5.1)
|
40
|
+
bundler
|
41
|
+
rake
|
42
|
+
arel (3.0.2)
|
43
|
+
builder (3.0.4)
|
44
|
+
crack (0.3.2)
|
45
|
+
diff-lcs (1.2.1)
|
46
|
+
erubis (2.7.0)
|
47
|
+
hike (1.2.1)
|
48
|
+
i18n (0.6.4)
|
49
|
+
journey (1.0.4)
|
50
|
+
json (1.7.7)
|
51
|
+
mail (2.4.4)
|
52
|
+
i18n (>= 0.4.0)
|
53
|
+
mime-types (~> 1.16)
|
54
|
+
treetop (~> 1.4.8)
|
55
|
+
mime-types (1.21)
|
56
|
+
multi_json (1.7.1)
|
57
|
+
polyglot (0.3.3)
|
58
|
+
rack (1.4.5)
|
59
|
+
rack-cache (1.2)
|
60
|
+
rack (>= 0.4)
|
61
|
+
rack-ssl (1.3.3)
|
62
|
+
rack
|
63
|
+
rack-test (0.6.2)
|
64
|
+
rack (>= 1.0)
|
65
|
+
rails (3.2.12)
|
66
|
+
actionmailer (= 3.2.12)
|
67
|
+
actionpack (= 3.2.12)
|
68
|
+
activerecord (= 3.2.12)
|
69
|
+
activeresource (= 3.2.12)
|
70
|
+
activesupport (= 3.2.12)
|
71
|
+
bundler (~> 1.0)
|
72
|
+
railties (= 3.2.12)
|
73
|
+
railties (3.2.12)
|
74
|
+
actionpack (= 3.2.12)
|
75
|
+
activesupport (= 3.2.12)
|
76
|
+
rack-ssl (~> 1.3.2)
|
77
|
+
rake (>= 0.8.7)
|
78
|
+
rdoc (~> 3.4)
|
79
|
+
thor (>= 0.14.6, < 2.0)
|
80
|
+
rake (10.0.3)
|
81
|
+
rdoc (3.12.2)
|
82
|
+
json (~> 1.4)
|
83
|
+
rest-client (1.6.7)
|
84
|
+
mime-types (>= 1.16)
|
85
|
+
rspec-core (2.13.1)
|
86
|
+
rspec-expectations (2.13.0)
|
87
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
88
|
+
rspec-mocks (2.13.0)
|
89
|
+
rspec-rails (2.13.0)
|
90
|
+
actionpack (>= 3.0)
|
91
|
+
activesupport (>= 3.0)
|
92
|
+
railties (>= 3.0)
|
93
|
+
rspec-core (~> 2.13.0)
|
94
|
+
rspec-expectations (~> 2.13.0)
|
95
|
+
rspec-mocks (~> 2.13.0)
|
96
|
+
sprockets (2.2.2)
|
97
|
+
hike (~> 1.2)
|
98
|
+
multi_json (~> 1.0)
|
99
|
+
rack (~> 1.0)
|
100
|
+
tilt (~> 1.1, != 1.3.0)
|
101
|
+
stripe (1.7.11)
|
102
|
+
multi_json (>= 1.0.4, < 2)
|
103
|
+
rest-client (~> 1.4)
|
104
|
+
thor (0.17.0)
|
105
|
+
tilt (1.3.6)
|
106
|
+
treetop (1.4.12)
|
107
|
+
polyglot
|
108
|
+
polyglot (>= 0.3.1)
|
109
|
+
tzinfo (0.3.37)
|
110
|
+
webmock (1.11.0)
|
111
|
+
addressable (>= 2.2.7)
|
112
|
+
crack (>= 0.3.2)
|
113
|
+
|
114
|
+
PLATFORMS
|
115
|
+
ruby
|
116
|
+
|
117
|
+
DEPENDENCIES
|
118
|
+
appraisal
|
119
|
+
rails (~> 3.1)
|
120
|
+
rspec-rails (~> 2.12)
|
121
|
+
stripe_event!
|
122
|
+
webmock (~> 1.9)
|
@@ -0,0 +1,122 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/dwhalen/Dropbox/stripe_event
|
3
|
+
specs:
|
4
|
+
stripe_event (0.6.0)
|
5
|
+
rails (>= 3.1)
|
6
|
+
stripe (~> 1.6)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.12)
|
12
|
+
actionpack (= 3.2.12)
|
13
|
+
mail (~> 2.4.4)
|
14
|
+
actionpack (3.2.12)
|
15
|
+
activemodel (= 3.2.12)
|
16
|
+
activesupport (= 3.2.12)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.4)
|
20
|
+
rack (~> 1.4.5)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.2.1)
|
24
|
+
activemodel (3.2.12)
|
25
|
+
activesupport (= 3.2.12)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.12)
|
28
|
+
activemodel (= 3.2.12)
|
29
|
+
activesupport (= 3.2.12)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.12)
|
33
|
+
activemodel (= 3.2.12)
|
34
|
+
activesupport (= 3.2.12)
|
35
|
+
activesupport (3.2.12)
|
36
|
+
i18n (~> 0.6)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
addressable (2.3.3)
|
39
|
+
appraisal (0.5.1)
|
40
|
+
bundler
|
41
|
+
rake
|
42
|
+
arel (3.0.2)
|
43
|
+
builder (3.0.4)
|
44
|
+
crack (0.3.2)
|
45
|
+
diff-lcs (1.2.1)
|
46
|
+
erubis (2.7.0)
|
47
|
+
hike (1.2.1)
|
48
|
+
i18n (0.6.4)
|
49
|
+
journey (1.0.4)
|
50
|
+
json (1.7.7)
|
51
|
+
mail (2.4.4)
|
52
|
+
i18n (>= 0.4.0)
|
53
|
+
mime-types (~> 1.16)
|
54
|
+
treetop (~> 1.4.8)
|
55
|
+
mime-types (1.21)
|
56
|
+
multi_json (1.7.1)
|
57
|
+
polyglot (0.3.3)
|
58
|
+
rack (1.4.5)
|
59
|
+
rack-cache (1.2)
|
60
|
+
rack (>= 0.4)
|
61
|
+
rack-ssl (1.3.3)
|
62
|
+
rack
|
63
|
+
rack-test (0.6.2)
|
64
|
+
rack (>= 1.0)
|
65
|
+
rails (3.2.12)
|
66
|
+
actionmailer (= 3.2.12)
|
67
|
+
actionpack (= 3.2.12)
|
68
|
+
activerecord (= 3.2.12)
|
69
|
+
activeresource (= 3.2.12)
|
70
|
+
activesupport (= 3.2.12)
|
71
|
+
bundler (~> 1.0)
|
72
|
+
railties (= 3.2.12)
|
73
|
+
railties (3.2.12)
|
74
|
+
actionpack (= 3.2.12)
|
75
|
+
activesupport (= 3.2.12)
|
76
|
+
rack-ssl (~> 1.3.2)
|
77
|
+
rake (>= 0.8.7)
|
78
|
+
rdoc (~> 3.4)
|
79
|
+
thor (>= 0.14.6, < 2.0)
|
80
|
+
rake (10.0.3)
|
81
|
+
rdoc (3.12.2)
|
82
|
+
json (~> 1.4)
|
83
|
+
rest-client (1.6.7)
|
84
|
+
mime-types (>= 1.16)
|
85
|
+
rspec-core (2.13.1)
|
86
|
+
rspec-expectations (2.13.0)
|
87
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
88
|
+
rspec-mocks (2.13.0)
|
89
|
+
rspec-rails (2.13.0)
|
90
|
+
actionpack (>= 3.0)
|
91
|
+
activesupport (>= 3.0)
|
92
|
+
railties (>= 3.0)
|
93
|
+
rspec-core (~> 2.13.0)
|
94
|
+
rspec-expectations (~> 2.13.0)
|
95
|
+
rspec-mocks (~> 2.13.0)
|
96
|
+
sprockets (2.2.2)
|
97
|
+
hike (~> 1.2)
|
98
|
+
multi_json (~> 1.0)
|
99
|
+
rack (~> 1.0)
|
100
|
+
tilt (~> 1.1, != 1.3.0)
|
101
|
+
stripe (1.7.11)
|
102
|
+
multi_json (>= 1.0.4, < 2)
|
103
|
+
rest-client (~> 1.4)
|
104
|
+
thor (0.17.0)
|
105
|
+
tilt (1.3.6)
|
106
|
+
treetop (1.4.12)
|
107
|
+
polyglot
|
108
|
+
polyglot (>= 0.3.1)
|
109
|
+
tzinfo (0.3.37)
|
110
|
+
webmock (1.11.0)
|
111
|
+
addressable (>= 2.2.7)
|
112
|
+
crack (>= 0.3.2)
|
113
|
+
|
114
|
+
PLATFORMS
|
115
|
+
ruby
|
116
|
+
|
117
|
+
DEPENDENCIES
|
118
|
+
appraisal
|
119
|
+
rails (~> 3.2)
|
120
|
+
rspec-rails (~> 2.12)
|
121
|
+
stripe_event!
|
122
|
+
webmock (~> 1.9)
|