stripe_event 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0d6619841f7069b8c12f167ffec6895a0d08fac
4
- data.tar.gz: ee91d70a34cffef31c804be916a55287789b0f66
3
+ metadata.gz: d2dcd509d7b185437e3955061006aa951aa03242
4
+ data.tar.gz: 67730b3dda4db7338ce20d07204c3ac2814ae799
5
5
  SHA512:
6
- metadata.gz: 746742414aab41ff384d07e1aaf4f9e548bf59f607b1a40adcfcbd4c09387810692bc3ff5f6df2b8a99d46083026ca3681c58054a5bed8ac63ac382326a38803
7
- data.tar.gz: b5691cb85b28b407594a058461886ac01d8db96b4413f651cc8c3491e9488910722d57d47d485a57f43282b7642e18424614fc57420e4db0068e6494acf9e6fb
6
+ metadata.gz: 88e1f14249d797216755f12cd584f90254b8f6a07497be1d890d0348578ffe908164f7c5bc416e0ca3f9526c6d7c4c4ae2af96fb9c0c8d6ed207310b8ab33a09
7
+ data.tar.gz: fc521a0db98550b61f045d00974af8da81dff81e311b6e173a9eee98ce55513944718693b0230794deaba2a05c950fa2829953dc0d2c03bd5fa17ab5ce095c84
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### 1.3.0 (July 22, 2014)
2
+ * Allow for ignoring particular events. Thank you to [anark](https://github.com/anark) for suggesting the change, and [Ryan McGeary](https://github.com/rmm5t) and [Pete Keen](https://github.com/peterkeen) for working on the implementation.
3
+
1
4
  ### 1.2.0 (June 17, 2014)
2
5
  * Gracefully authenticate `account.application.deauthorized` events. Thank you to [Ryan McGeary](https://github.com/rmm5t) for the pull request and for taking the time to test the change in a live environment.
3
6
 
data/README.md CHANGED
@@ -98,6 +98,23 @@ end
98
98
  StripeEvent.event_retriever = EventRetriever.new
99
99
  ```
100
100
 
101
+ If you'd like to ignore particular webhook events (perhaps to ignore test webhooks in production, or to ignore webhooks for a non-paying customer), you can do so by returning `nil` in you custom `event_retriever`. For example:
102
+
103
+ ```ruby
104
+ StripeEvent.event_retriever = lambda do |params|
105
+ return nil if Rails.env.production && !params[:livemode]
106
+ Stripe::Event.retrieve(params[:id])
107
+ end
108
+ ```
109
+
110
+ ```ruby
111
+ StripeEvent.event_retriever = lambda do |params|
112
+ account = Account.find_by!(stripe_user_id: params[:user_id])
113
+ return nil if account.delinquent?
114
+ Stripe::Event.retrieve(params[:id], account.api_key)
115
+ end
116
+ ```
117
+
101
118
  ## Without Rails
102
119
 
103
120
  StripeEvent can be used outside of Rails applications as well. Here is a basic Sinatra implementation:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- stripe_event (1.2.0)
4
+ stripe_event (1.3.0)
5
5
  activesupport (>= 3.1)
6
6
  stripe (~> 1.6)
7
7
 
@@ -36,10 +36,11 @@ GEM
36
36
  activesupport (= 3.1.12)
37
37
  activesupport (3.1.12)
38
38
  multi_json (~> 1.0)
39
- addressable (2.3.5)
40
- appraisal (0.5.2)
39
+ addressable (2.3.6)
40
+ appraisal (1.0.0)
41
41
  bundler
42
42
  rake
43
+ thor (>= 0.14.0)
43
44
  arel (2.2.3)
44
45
  builder (3.0.4)
45
46
  coveralls (0.7.0)
@@ -48,10 +49,10 @@ GEM
48
49
  simplecov (>= 0.7)
49
50
  term-ansicolor
50
51
  thor
51
- crack (0.4.1)
52
- safe_yaml (~> 0.9.0)
52
+ crack (0.4.2)
53
+ safe_yaml (~> 1.0.0)
53
54
  diff-lcs (1.2.5)
54
- docile (1.1.1)
55
+ docile (1.1.3)
55
56
  erubis (2.7.0)
56
57
  hike (1.2.3)
57
58
  i18n (0.6.9)
@@ -61,14 +62,14 @@ GEM
61
62
  mime-types (~> 1.16)
62
63
  treetop (~> 1.4.8)
63
64
  mime-types (1.25.1)
64
- multi_json (1.8.2)
65
- polyglot (0.3.3)
65
+ multi_json (1.10.1)
66
+ polyglot (0.3.4)
66
67
  rack (1.3.10)
67
68
  rack-cache (1.2)
68
69
  rack (>= 0.4)
69
70
  rack-mount (0.8.3)
70
71
  rack (>= 1.0.0)
71
- rack-ssl (1.3.3)
72
+ rack-ssl (1.3.4)
72
73
  rack
73
74
  rack-test (0.6.2)
74
75
  rack (>= 1.0)
@@ -87,23 +88,24 @@ GEM
87
88
  rake (>= 0.8.7)
88
89
  rdoc (~> 3.4)
89
90
  thor (~> 0.14.6)
90
- rake (10.1.0)
91
+ rake (10.3.2)
91
92
  rdoc (3.12.2)
92
93
  json (~> 1.4)
93
94
  rest-client (1.6.7)
94
95
  mime-types (>= 1.16)
95
- rspec-core (2.14.7)
96
- rspec-expectations (2.14.4)
96
+ rspec-core (2.14.8)
97
+ rspec-expectations (2.14.5)
97
98
  diff-lcs (>= 1.1.3, < 2.0)
98
- rspec-mocks (2.14.4)
99
- rspec-rails (2.14.0)
99
+ rspec-mocks (2.14.6)
100
+ rspec-rails (2.14.2)
100
101
  actionpack (>= 3.0)
102
+ activemodel (>= 3.0)
101
103
  activesupport (>= 3.0)
102
104
  railties (>= 3.0)
103
105
  rspec-core (~> 2.14.0)
104
106
  rspec-expectations (~> 2.14.0)
105
107
  rspec-mocks (~> 2.14.0)
106
- safe_yaml (0.9.7)
108
+ safe_yaml (1.0.3)
107
109
  simplecov (0.8.2)
108
110
  docile (~> 1.1.0)
109
111
  multi_json
@@ -117,16 +119,16 @@ GEM
117
119
  json (~> 1.8.1)
118
120
  mime-types (~> 1.25)
119
121
  rest-client (~> 1.4)
120
- term-ansicolor (1.2.2)
121
- tins (~> 0.8)
122
+ term-ansicolor (1.3.0)
123
+ tins (~> 1.0)
122
124
  thor (0.14.6)
123
125
  tilt (1.4.1)
124
- tins (0.13.1)
126
+ tins (1.1.0)
125
127
  treetop (1.4.15)
126
128
  polyglot
127
129
  polyglot (>= 0.3.1)
128
- tzinfo (0.3.38)
129
- webmock (1.16.0)
130
+ tzinfo (0.3.39)
131
+ webmock (1.17.4)
130
132
  addressable (>= 2.2.7)
131
133
  crack (>= 0.3.2)
132
134
 
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- stripe_event (1.2.0)
4
+ stripe_event (1.3.0)
5
5
  activesupport (>= 3.1)
6
6
  stripe (~> 1.6)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionmailer (3.2.16)
12
- actionpack (= 3.2.16)
11
+ actionmailer (3.2.18)
12
+ actionpack (= 3.2.18)
13
13
  mail (~> 2.5.4)
14
- actionpack (3.2.16)
15
- activemodel (= 3.2.16)
16
- activesupport (= 3.2.16)
14
+ actionpack (3.2.18)
15
+ activemodel (= 3.2.18)
16
+ activesupport (= 3.2.18)
17
17
  builder (~> 3.0.0)
18
18
  erubis (~> 2.7.0)
19
19
  journey (~> 1.0.4)
@@ -21,24 +21,25 @@ GEM
21
21
  rack-cache (~> 1.2)
22
22
  rack-test (~> 0.6.1)
23
23
  sprockets (~> 2.2.1)
24
- activemodel (3.2.16)
25
- activesupport (= 3.2.16)
24
+ activemodel (3.2.18)
25
+ activesupport (= 3.2.18)
26
26
  builder (~> 3.0.0)
27
- activerecord (3.2.16)
28
- activemodel (= 3.2.16)
29
- activesupport (= 3.2.16)
27
+ activerecord (3.2.18)
28
+ activemodel (= 3.2.18)
29
+ activesupport (= 3.2.18)
30
30
  arel (~> 3.0.2)
31
31
  tzinfo (~> 0.3.29)
32
- activeresource (3.2.16)
33
- activemodel (= 3.2.16)
34
- activesupport (= 3.2.16)
35
- activesupport (3.2.16)
32
+ activeresource (3.2.18)
33
+ activemodel (= 3.2.18)
34
+ activesupport (= 3.2.18)
35
+ activesupport (3.2.18)
36
36
  i18n (~> 0.6, >= 0.6.4)
37
37
  multi_json (~> 1.0)
38
- addressable (2.3.5)
39
- appraisal (0.5.2)
38
+ addressable (2.3.6)
39
+ appraisal (1.0.0)
40
40
  bundler
41
41
  rake
42
+ thor (>= 0.14.0)
42
43
  arel (3.0.3)
43
44
  builder (3.0.4)
44
45
  coveralls (0.7.0)
@@ -47,10 +48,10 @@ GEM
47
48
  simplecov (>= 0.7)
48
49
  term-ansicolor
49
50
  thor
50
- crack (0.4.1)
51
- safe_yaml (~> 0.9.0)
51
+ crack (0.4.2)
52
+ safe_yaml (~> 1.0.0)
52
53
  diff-lcs (1.2.5)
53
- docile (1.1.1)
54
+ docile (1.1.3)
54
55
  erubis (2.7.0)
55
56
  hike (1.2.3)
56
57
  i18n (0.6.9)
@@ -60,47 +61,48 @@ GEM
60
61
  mime-types (~> 1.16)
61
62
  treetop (~> 1.4.8)
62
63
  mime-types (1.25.1)
63
- multi_json (1.8.2)
64
- polyglot (0.3.3)
64
+ multi_json (1.10.1)
65
+ polyglot (0.3.4)
65
66
  rack (1.4.5)
66
67
  rack-cache (1.2)
67
68
  rack (>= 0.4)
68
- rack-ssl (1.3.3)
69
+ rack-ssl (1.3.4)
69
70
  rack
70
71
  rack-test (0.6.2)
71
72
  rack (>= 1.0)
72
- rails (3.2.16)
73
- actionmailer (= 3.2.16)
74
- actionpack (= 3.2.16)
75
- activerecord (= 3.2.16)
76
- activeresource (= 3.2.16)
77
- activesupport (= 3.2.16)
73
+ rails (3.2.18)
74
+ actionmailer (= 3.2.18)
75
+ actionpack (= 3.2.18)
76
+ activerecord (= 3.2.18)
77
+ activeresource (= 3.2.18)
78
+ activesupport (= 3.2.18)
78
79
  bundler (~> 1.0)
79
- railties (= 3.2.16)
80
- railties (3.2.16)
81
- actionpack (= 3.2.16)
82
- activesupport (= 3.2.16)
80
+ railties (= 3.2.18)
81
+ railties (3.2.18)
82
+ actionpack (= 3.2.18)
83
+ activesupport (= 3.2.18)
83
84
  rack-ssl (~> 1.3.2)
84
85
  rake (>= 0.8.7)
85
86
  rdoc (~> 3.4)
86
87
  thor (>= 0.14.6, < 2.0)
87
- rake (10.1.0)
88
+ rake (10.3.2)
88
89
  rdoc (3.12.2)
89
90
  json (~> 1.4)
90
91
  rest-client (1.6.7)
91
92
  mime-types (>= 1.16)
92
- rspec-core (2.14.7)
93
- rspec-expectations (2.14.4)
93
+ rspec-core (2.14.8)
94
+ rspec-expectations (2.14.5)
94
95
  diff-lcs (>= 1.1.3, < 2.0)
95
- rspec-mocks (2.14.4)
96
- rspec-rails (2.14.0)
96
+ rspec-mocks (2.14.6)
97
+ rspec-rails (2.14.2)
97
98
  actionpack (>= 3.0)
99
+ activemodel (>= 3.0)
98
100
  activesupport (>= 3.0)
99
101
  railties (>= 3.0)
100
102
  rspec-core (~> 2.14.0)
101
103
  rspec-expectations (~> 2.14.0)
102
104
  rspec-mocks (~> 2.14.0)
103
- safe_yaml (0.9.7)
105
+ safe_yaml (1.0.3)
104
106
  simplecov (0.8.2)
105
107
  docile (~> 1.1.0)
106
108
  multi_json
@@ -115,16 +117,16 @@ GEM
115
117
  json (~> 1.8.1)
116
118
  mime-types (~> 1.25)
117
119
  rest-client (~> 1.4)
118
- term-ansicolor (1.2.2)
119
- tins (~> 0.8)
120
- thor (0.18.1)
120
+ term-ansicolor (1.3.0)
121
+ tins (~> 1.0)
122
+ thor (0.19.1)
121
123
  tilt (1.4.1)
122
- tins (0.13.1)
124
+ tins (1.1.0)
123
125
  treetop (1.4.15)
124
126
  polyglot
125
127
  polyglot (>= 0.3.1)
126
- tzinfo (0.3.38)
127
- webmock (1.16.0)
128
+ tzinfo (0.3.39)
129
+ webmock (1.17.4)
128
130
  addressable (>= 2.2.7)
129
131
  crack (>= 0.3.2)
130
132
 
@@ -1,43 +1,43 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- stripe_event (1.2.0)
4
+ stripe_event (1.3.0)
5
5
  activesupport (>= 3.1)
6
6
  stripe (~> 1.6)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionmailer (4.0.2)
12
- actionpack (= 4.0.2)
11
+ actionmailer (4.0.5)
12
+ actionpack (= 4.0.5)
13
13
  mail (~> 2.5.4)
14
- actionpack (4.0.2)
15
- activesupport (= 4.0.2)
14
+ actionpack (4.0.5)
15
+ activesupport (= 4.0.5)
16
16
  builder (~> 3.1.0)
17
17
  erubis (~> 2.7.0)
18
18
  rack (~> 1.5.2)
19
19
  rack-test (~> 0.6.2)
20
- activemodel (4.0.2)
21
- activesupport (= 4.0.2)
20
+ activemodel (4.0.5)
21
+ activesupport (= 4.0.5)
22
22
  builder (~> 3.1.0)
23
- activerecord (4.0.2)
24
- activemodel (= 4.0.2)
23
+ activerecord (4.0.5)
24
+ activemodel (= 4.0.5)
25
25
  activerecord-deprecated_finders (~> 1.0.2)
26
- activesupport (= 4.0.2)
26
+ activesupport (= 4.0.5)
27
27
  arel (~> 4.0.0)
28
28
  activerecord-deprecated_finders (1.0.3)
29
- activesupport (4.0.2)
30
- i18n (~> 0.6, >= 0.6.4)
29
+ activesupport (4.0.5)
30
+ i18n (~> 0.6, >= 0.6.9)
31
31
  minitest (~> 4.2)
32
32
  multi_json (~> 1.3)
33
33
  thread_safe (~> 0.1)
34
34
  tzinfo (~> 0.3.37)
35
- addressable (2.3.5)
36
- appraisal (0.5.2)
35
+ addressable (2.3.6)
36
+ appraisal (1.0.0)
37
37
  bundler
38
38
  rake
39
- arel (4.0.1)
40
- atomic (1.1.14)
39
+ thor (>= 0.14.0)
40
+ arel (4.0.2)
41
41
  builder (3.1.4)
42
42
  coveralls (0.7.0)
43
43
  multi_json (~> 1.3)
@@ -45,10 +45,10 @@ GEM
45
45
  simplecov (>= 0.7)
46
46
  term-ansicolor
47
47
  thor
48
- crack (0.4.1)
49
- safe_yaml (~> 0.9.0)
48
+ crack (0.4.2)
49
+ safe_yaml (~> 1.0.0)
50
50
  diff-lcs (1.2.5)
51
- docile (1.1.1)
51
+ docile (1.1.3)
52
52
  erubis (2.7.0)
53
53
  hike (1.2.3)
54
54
  i18n (0.6.9)
@@ -58,45 +58,46 @@ GEM
58
58
  treetop (~> 1.4.8)
59
59
  mime-types (1.25.1)
60
60
  minitest (4.7.5)
61
- multi_json (1.8.2)
62
- polyglot (0.3.3)
61
+ multi_json (1.10.1)
62
+ polyglot (0.3.4)
63
63
  rack (1.5.2)
64
64
  rack-test (0.6.2)
65
65
  rack (>= 1.0)
66
- rails (4.0.2)
67
- actionmailer (= 4.0.2)
68
- actionpack (= 4.0.2)
69
- activerecord (= 4.0.2)
70
- activesupport (= 4.0.2)
66
+ rails (4.0.5)
67
+ actionmailer (= 4.0.5)
68
+ actionpack (= 4.0.5)
69
+ activerecord (= 4.0.5)
70
+ activesupport (= 4.0.5)
71
71
  bundler (>= 1.3.0, < 2.0)
72
- railties (= 4.0.2)
72
+ railties (= 4.0.5)
73
73
  sprockets-rails (~> 2.0.0)
74
- railties (4.0.2)
75
- actionpack (= 4.0.2)
76
- activesupport (= 4.0.2)
74
+ railties (4.0.5)
75
+ actionpack (= 4.0.5)
76
+ activesupport (= 4.0.5)
77
77
  rake (>= 0.8.7)
78
78
  thor (>= 0.18.1, < 2.0)
79
- rake (10.1.0)
79
+ rake (10.3.2)
80
80
  rest-client (1.6.7)
81
81
  mime-types (>= 1.16)
82
- rspec-core (2.14.7)
83
- rspec-expectations (2.14.4)
82
+ rspec-core (2.14.8)
83
+ rspec-expectations (2.14.5)
84
84
  diff-lcs (>= 1.1.3, < 2.0)
85
- rspec-mocks (2.14.4)
86
- rspec-rails (2.14.0)
85
+ rspec-mocks (2.14.6)
86
+ rspec-rails (2.14.2)
87
87
  actionpack (>= 3.0)
88
+ activemodel (>= 3.0)
88
89
  activesupport (>= 3.0)
89
90
  railties (>= 3.0)
90
91
  rspec-core (~> 2.14.0)
91
92
  rspec-expectations (~> 2.14.0)
92
93
  rspec-mocks (~> 2.14.0)
93
- safe_yaml (0.9.7)
94
+ safe_yaml (1.0.3)
94
95
  simplecov (0.8.2)
95
96
  docile (~> 1.1.0)
96
97
  multi_json
97
98
  simplecov-html (~> 0.8.0)
98
99
  simplecov-html (0.8.0)
99
- sprockets (2.10.1)
100
+ sprockets (2.12.1)
100
101
  hike (~> 1.2)
101
102
  multi_json (~> 1.0)
102
103
  rack (~> 1.0)
@@ -109,18 +110,17 @@ GEM
109
110
  json (~> 1.8.1)
110
111
  mime-types (~> 1.25)
111
112
  rest-client (~> 1.4)
112
- term-ansicolor (1.2.2)
113
- tins (~> 0.8)
114
- thor (0.18.1)
115
- thread_safe (0.1.3)
116
- atomic
113
+ term-ansicolor (1.3.0)
114
+ tins (~> 1.0)
115
+ thor (0.19.1)
116
+ thread_safe (0.3.4)
117
117
  tilt (1.4.1)
118
- tins (0.13.1)
118
+ tins (1.1.0)
119
119
  treetop (1.4.15)
120
120
  polyglot
121
121
  polyglot (>= 0.3.1)
122
- tzinfo (0.3.38)
123
- webmock (1.16.0)
122
+ tzinfo (0.3.39)
123
+ webmock (1.17.4)
124
124
  addressable (>= 2.2.7)
125
125
  crack (>= 0.3.2)
126
126
 
data/lib/stripe_event.rb CHANGED
@@ -25,7 +25,7 @@ module StripeEvent
25
25
  raise UnauthorizedError.new(e)
26
26
  end
27
27
 
28
- backend.instrument namespace.call(event[:type]), event
28
+ backend.instrument namespace.call(event[:type]), event if event
29
29
  end
30
30
 
31
31
  def subscribe(name, callable = Proc.new)
@@ -1,3 +1,3 @@
1
1
  module StripeEvent
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -22,6 +22,18 @@ describe StripeEvent::WebhookController do
22
22
  expect(count).to eq 1
23
23
  end
24
24
 
25
+ it "succeeds when the event_retriever returns nil (simulating an ignored webhook event)" do
26
+ count = 0
27
+ StripeEvent.event_retriever = lambda { |params| return nil }
28
+ StripeEvent.subscribe('charge.succeeded') { |evt| count += 1 }
29
+ stub_event('evt_charge_succeeded')
30
+
31
+ webhook id: 'evt_charge_succeeded'
32
+
33
+ expect(response.code).to eq '200'
34
+ expect(count).to eq 0
35
+ end
36
+
25
37
  it "denies access with invalid event data" do
26
38
  count = 0
27
39
  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.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Whalen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport