stripe_event 1.5.0 → 1.5.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -6
- data/CONTRIBUTING.md +43 -0
- data/README.md +13 -3
- data/app/controllers/stripe_event/webhook_controller.rb +22 -8
- data/lib/stripe_event/version.rb +1 -1
- data/spec/controllers/webhook_controller_spec.rb +3 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8f2db054ffda395b617ea68f31e2b424edbb2e
|
4
|
+
data.tar.gz: 06ac2c82777ac0034f1ed6816f2af05efc4b3f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9212f24254702fa2486e9a9f3f5e88cb90f662b1e3d990daa62749c33d513181b7fe405f8724b299e355f62c7bae758db2b09a9febb6630d144157b530bc5fd0
|
7
|
+
data.tar.gz: e211859259774381b070b21bb615db7bb0a7d384993d446209391921e7094492bfc39c9b800cf64fee830e958d55467ad103f890145c939b296b0c9e54b0942c
|
data/.travis.yml
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
sudo: false
|
2
4
|
|
3
5
|
rvm:
|
4
|
-
-
|
5
|
-
- 2.
|
6
|
-
- jruby-19mode
|
6
|
+
- 2.2
|
7
|
+
- 2.3.0
|
7
8
|
|
8
9
|
gemfile:
|
9
|
-
- gemfiles/rails3.2.gemfile
|
10
10
|
- gemfiles/rails4.1.gemfile
|
11
11
|
- gemfiles/rails4.2.gemfile
|
12
12
|
|
13
|
-
sudo: false
|
14
|
-
|
15
13
|
matrix:
|
14
|
+
include:
|
15
|
+
- rvm: 2.1
|
16
|
+
gemfile: gemfiles/rails3.2.gemfile
|
17
|
+
- rvm: jruby-19mode
|
18
|
+
gemfile: gemfiles/rails3.2.gemfile
|
16
19
|
fast_finish: true
|
17
20
|
|
18
21
|
notifications:
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
## Want to Contribute?
|
2
|
+
|
3
|
+
Awesome. We love help, but before getting started, please read:
|
4
|
+
|
5
|
+
**[Don't "Push" Your Pull Requests](http://www.igvita.com/2011/12/19/dont-push-your-pull-requests/)**
|
6
|
+
|
7
|
+
## Ready for a Pull-Request?
|
8
|
+
|
9
|
+
1. Fork the repo.
|
10
|
+
|
11
|
+
2. Run the tests. We only take pull requests with passing tests, and it's great
|
12
|
+
to know that you have a clean slate: `bundle && appraisal && bundle exec rake`
|
13
|
+
|
14
|
+
3. Add a test for your change. Only refactoring and documentation changes
|
15
|
+
require no new tests. If you are adding functionality or fixing a bug, we need
|
16
|
+
a test!
|
17
|
+
|
18
|
+
4. Make the test pass.
|
19
|
+
|
20
|
+
5. Push to your fork and submit a pull request.
|
21
|
+
|
22
|
+
At this point you're waiting on us. We like to at least comment on, if not
|
23
|
+
accept, pull requests within three business days (and, typically, one business
|
24
|
+
day). We may suggest some changes or improvements or alternatives.
|
25
|
+
|
26
|
+
Some things that will increase the chance that your pull request is accepted,
|
27
|
+
taken straight from the Ruby on Rails guide:
|
28
|
+
|
29
|
+
## Conventions
|
30
|
+
|
31
|
+
* Use Rails idioms and helpers.
|
32
|
+
* Include tests that fail without your code, and pass with your code.
|
33
|
+
* Update the documentation, the surrounding one, examples elsewhere, guides,
|
34
|
+
whatever is affected by your contribution
|
35
|
+
|
36
|
+
Syntax:
|
37
|
+
|
38
|
+
* Two spaces, no tabs.
|
39
|
+
* No trailing whitespace. Blank lines should not have any space.
|
40
|
+
* Prefer `&&`/`||` over `and`/`or`.
|
41
|
+
* `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
|
42
|
+
* `a = b` not `a=b`.
|
43
|
+
* Follow the conventions you see used in the source already.
|
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# StripeEvent
|
2
|
-
|
2
|
+
|
3
|
+
[](http://travis-ci.org/integrallis/stripe_event)
|
4
|
+
[](https://gemnasium.com/integrallis/stripe_event)
|
5
|
+
[](http://badge.fury.io/rb/stripe_event)
|
6
|
+
[](https://codeclimate.com/github/integrallis/stripe_event)
|
7
|
+
[](https://coveralls.io/r/integrallis/stripe_event)
|
8
|
+
[](https://rubygems.org/gems/stripe_event)
|
3
9
|
|
4
10
|
StripeEvent 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#retrieve_event) from Stripe. Define subscribers to handle specific event types. Subscribers can be a block or an object that responds to `#call`.
|
5
11
|
|
@@ -19,7 +25,7 @@ mount StripeEvent::Engine, at: '/my-chosen-path' # provide a custom path
|
|
19
25
|
|
20
26
|
```ruby
|
21
27
|
# config/initializers/stripe.rb
|
22
|
-
Stripe.api_key = ENV['
|
28
|
+
Stripe.api_key = ENV['STRIPE_SECRET_KEY'] # e.g. sk_live_1234
|
23
29
|
|
24
30
|
StripeEvent.configure do |events|
|
25
31
|
events.subscribe 'charge.failed' do |event|
|
@@ -147,7 +153,7 @@ require 'json'
|
|
147
153
|
require 'sinatra'
|
148
154
|
require 'stripe_event'
|
149
155
|
|
150
|
-
Stripe.api_key = ENV['
|
156
|
+
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
151
157
|
|
152
158
|
StripeEvent.subscribe 'charge.failed' do |event|
|
153
159
|
# Look ma, no Rails!
|
@@ -200,6 +206,10 @@ This button sends an example event to your webhook urls, including an `id` of `e
|
|
200
206
|
|
201
207
|
Special thanks to all the [contributors](https://github.com/integrallis/stripe_event/graphs/contributors).
|
202
208
|
|
209
|
+
### Versioning
|
210
|
+
|
211
|
+
Semantic Versioning 2.0 as defined at <http://semver.org>.
|
212
|
+
|
203
213
|
### License
|
204
214
|
|
205
215
|
[MIT License](https://github.com/integrallis/stripe_event/blob/master/LICENSE.md). Copyright 2012-2015 Integrallis Software.
|
@@ -1,18 +1,32 @@
|
|
1
1
|
module StripeEvent
|
2
2
|
class WebhookController < ActionController::Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
end
|
3
|
+
if respond_to?(:before_action)
|
4
|
+
before_action :request_authentication
|
5
|
+
else
|
6
|
+
before_filter :request_authentication
|
9
7
|
end
|
10
|
-
|
8
|
+
|
11
9
|
def event
|
12
10
|
StripeEvent.instrument(params)
|
13
11
|
head :ok
|
14
|
-
rescue StripeEvent::UnauthorizedError
|
12
|
+
rescue StripeEvent::UnauthorizedError => e
|
13
|
+
log_error(e)
|
15
14
|
head :unauthorized
|
16
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def log_error(e)
|
20
|
+
logger.error e.message
|
21
|
+
e.backtrace.each { |line| logger.error " #{line}" }
|
22
|
+
end
|
23
|
+
|
24
|
+
def request_authentication
|
25
|
+
if StripeEvent.authentication_secret
|
26
|
+
authenticate_or_request_with_http_basic do |username, password|
|
27
|
+
password == StripeEvent.authentication_secret
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
17
31
|
end
|
18
32
|
end
|
data/lib/stripe_event/version.rb
CHANGED
@@ -8,9 +8,11 @@ describe StripeEvent::WebhookController do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def webhook(params)
|
11
|
-
post :event, params
|
11
|
+
post :event, params
|
12
12
|
end
|
13
13
|
|
14
|
+
routes { StripeEvent::Engine.routes }
|
15
|
+
|
14
16
|
it "succeeds with valid event data" do
|
15
17
|
count = 0
|
16
18
|
StripeEvent.subscribe('charge.succeeded') { |evt| count += 1 }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe_event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Whalen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".travis.yml"
|
120
120
|
- Appraisals
|
121
121
|
- CHANGELOG.md
|
122
|
+
- CONTRIBUTING.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.md
|
124
125
|
- README.md
|
@@ -189,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
192
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.4
|
193
|
+
rubygems_version: 2.6.4
|
193
194
|
signing_key:
|
194
195
|
specification_version: 4
|
195
196
|
summary: Stripe webhook integration for Rails applications.
|