stripe_event 2.3.0 → 2.4.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
  SHA256:
3
- metadata.gz: 622e6067f00eb0c34af4261c16e7ddee15a0dc3938d12121154827cd5fc78453
4
- data.tar.gz: 0f5135cb03f10177a68bbb07762dfc43e8acdac1d4453fe795b3307673f75b3f
3
+ metadata.gz: 24784862569e458b05d7c6fcbb6f06fe7dffbca6f72aea86ac0563f11bedf134
4
+ data.tar.gz: f9628159d783d831f826f43885efba0cc4748c306d7513e0d0a0c2f36704c3f6
5
5
  SHA512:
6
- metadata.gz: fea8d1feadced10288c2f663b54cc6b497485a3b25e27d002330fe24c2fbb9e4d67d8beda3c555c1c9fa5beb8dece21987e5c4a514bde9cbb96aa540b1679c5e
7
- data.tar.gz: 6087e16c92ea14b3e34381589763c0b27ccc2d67296f63f7368e56b3f24acfba895376edee81e890515dcfd50f8453364bfb6ece68f4912de0d5d5e2daf84cc4
6
+ metadata.gz: b71b8f0ec702b4c292f508e7bb5b5ddc5c2f2ae3f1d238ca46b046dfbe9cc69127215e3d2e77156c26982e43aeec97c62c12beb90eb9d166e0ce6f1193d81800
7
+ data.tar.gz: 52d0c8a926be01d59e99d4c83dd0d55c2c8ab053c937980708a39556acaf200928f5a59861d44c9dd800f99aa43227b8cc5d03303e73bd64398e96943bcc8429
@@ -0,0 +1,50 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [master]
5
+ pull_request:
6
+ branches: [master]
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ ruby: ["2.7", "3.0", "3.1"]
14
+ bundler: [default]
15
+ gemfile:
16
+ - rails6.0
17
+ - rails6.1
18
+ - rails7.0
19
+ - stripe5
20
+ - stripe6
21
+ include:
22
+ - { ruby: "2.3", gemfile: "rails3.2", bundler: "1" }
23
+ - { ruby: "2.3", gemfile: "rails4.2", bundler: "1" }
24
+ - { ruby: "2.4", gemfile: "rails4.2", bundler: "1" }
25
+ - { ruby: "2.5", gemfile: "rails5.1", bundler: "default" }
26
+ - { ruby: "2.5", gemfile: "rails5.2", bundler: "default" }
27
+ - { ruby: "2.6", gemfile: "rails5.2", bundler: "default" }
28
+ - { ruby: "2.6", gemfile: "rails6.0", bundler: "default" }
29
+ - { ruby: "2.6", gemfile: "rails6.1", bundler: "default" }
30
+ - { ruby: "2.5", gemfile: "stripe3", bundler: "default" }
31
+ - { ruby: "2.6", gemfile: "stripe3", bundler: "default" }
32
+ - { ruby: "2.7", gemfile: "stripe3", bundler: "default" }
33
+ - { ruby: "2.5", gemfile: "stripe4", bundler: "default" }
34
+ - { ruby: "2.6", gemfile: "stripe4", bundler: "default" }
35
+ - { ruby: "2.7", gemfile: "stripe4", bundler: "default" }
36
+
37
+ env:
38
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
39
+ steps:
40
+ # https://github.com/marketplace/actions/checkout
41
+ - uses: actions/checkout@v2
42
+ # https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
43
+ - name: Set up Ruby
44
+ uses: ruby/setup-ruby@v1
45
+ with:
46
+ ruby-version: ${{ matrix.ruby }}
47
+ bundler: ${{ matrix.bundler }}
48
+ bundler-cache: true # runs `bundle install` and caches gems automatically
49
+ - name: Run tests
50
+ run: bundle exec rake
data/Appraisals CHANGED
@@ -19,6 +19,14 @@ appraise "rails6.0" do
19
19
  gem "rails", "~> 6.0.0"
20
20
  end
21
21
 
22
+ appraise "rails6.1" do
23
+ gem "rails", "~> 6.1.0"
24
+ end
25
+
26
+ appraise "rails7.0" do
27
+ gem "rails", "~> 7.0.0"
28
+ end
29
+
22
30
  appraise "stripe3" do
23
31
  gem "stripe", "~> 3.0"
24
32
  end
@@ -31,6 +39,10 @@ appraise "stripe5" do
31
39
  gem "stripe", "~> 5.0"
32
40
  end
33
41
 
42
+ appraise "stripe6" do
43
+ gem "stripe", "~> 6.0"
44
+ end
45
+
34
46
  appraise "rails_master" do
35
47
  gem "rails", github: "rails"
36
48
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ### 2.4.0 (May 12, 2022)
2
+
3
+ - Add Stripe 6 support (#151)
4
+ - Add Rails 7 support (#151)
5
+ - Add Ruby 3.1 support (#152)
6
+ - Improved build matrix
7
+
8
+ ### 2.3.2 (February 21, 2022)
9
+
10
+ - Fix signature validation error if the first signing secret is nil (#146)
11
+ - Update README (#143)
12
+ - Setup github actions for CI (#147)
13
+
14
+ ### 2.3.1 (May 12, 2020)
15
+
16
+ - Fix deprecation warning in Ruby 2.7 (#130)
17
+ - Fixes tests for Stripe 5.19.0 (#133)
18
+
1
19
  ### 2.3.0 (August 23, 2019)
2
20
 
3
21
  - Add support for Stripe v5.x (#119)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # StripeEvent
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/integrallis/stripe_event.svg)](http://travis-ci.org/integrallis/stripe_event)
3
+ [![Build Status](https://github.com/integrallis/stripe_event/workflows/CI/badge.svg)](https://github.com/integrallis/stripe_event/actions?query=workflow%3ACI)
4
4
  [![Gem Version](https://badge.fury.io/rb/stripe_event.svg)](http://badge.fury.io/rb/stripe_event)
5
5
  [![Code Climate](https://codeclimate.com/github/integrallis/stripe_event.svg)](https://codeclimate.com/github/integrallis/stripe_event)
6
6
  [![Coverage Status](https://coveralls.io/repos/integrallis/stripe_event/badge.svg)](https://coveralls.io/r/integrallis/stripe_event)
@@ -105,13 +105,6 @@ StripeEvent.signing_secrets = [
105
105
 
106
106
  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 [account parameter](https://stripe.com/docs/connect/webhooks) from the top level to detect the customer for the event, then grab their specific API key). You can do this:
107
107
 
108
- ```ruby
109
- StripeEvent.event_filter = lambda do |event|
110
- api_key = Account.find_by!(stripe_account_id: event.account).api_key
111
- Stripe::Event.retrieve(event.id, api_key)
112
- end
113
- ```
114
-
115
108
  ```ruby
116
109
  class EventFilter
117
110
  def call(event)
@@ -176,7 +169,7 @@ Handling webhooks is a critical piece of modern billing systems. Verifying the b
176
169
 
177
170
  ```ruby
178
171
  # spec/requests/billing_events_spec.rb
179
- require 'spec_helper'
172
+ require 'rails_helper'
180
173
 
181
174
  describe "Billing Events" do
182
175
  def bypass_event_signature(payload)
@@ -185,12 +178,12 @@ describe "Billing Events" do
185
178
  end
186
179
 
187
180
  describe "customer.created" do
188
- let(:payload) { File.read("spec/support/fixtures/evt_customer_created.json") }
189
- before(:each) { bypass_event_signature payload }
181
+ let(:payload) { file_fixture('evt_customer_created.json').read }
182
+ before(:each) { bypass_event_signature(payload) }
190
183
 
191
184
  it "is successful" do
192
- post '/_billing_events', body: payload
193
- expect(response.code).to eq "200"
185
+ post '/_billing_events', params: payload
186
+ expect(response).to have_http_status(:success)
194
187
  # Additional expectations...
195
188
  end
196
189
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.1.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.0.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "stripe", "~> 6.0"
6
+
7
+ gemspec path: "../"
@@ -1,3 +1,3 @@
1
1
  module StripeEvent
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
data/lib/stripe_event.rb CHANGED
@@ -18,11 +18,13 @@ module StripeEvent
18
18
  backend.instrument namespace.call(event.type), event if event
19
19
  end
20
20
 
21
- def subscribe(name, callable = Proc.new)
21
+ def subscribe(name, callable = nil, &block)
22
+ callable ||= block
22
23
  backend.subscribe namespace.to_regexp(name), adapter.call(callable)
23
24
  end
24
25
 
25
- def all(callable = Proc.new)
26
+ def all(callable = nil, &block)
27
+ callable ||= block
26
28
  subscribe nil, callable
27
29
  end
28
30
 
@@ -32,7 +34,7 @@ module StripeEvent
32
34
  end
33
35
 
34
36
  def signing_secret=(value)
35
- @signing_secrets = Array(value)
37
+ @signing_secrets = Array(value).compact
36
38
  end
37
39
  alias signing_secrets= signing_secret=
38
40
 
@@ -12,10 +12,19 @@ describe StripeEvent::WebhookController, type: :controller do
12
12
 
13
13
  def generate_signature(params, secret)
14
14
  payload = params.to_json
15
- timestamp = Time.now.to_i
16
- signature = Stripe::Webhook::Signature.send(:compute_signature, "#{timestamp}.#{payload}", secret)
17
-
18
- "t=#{timestamp},v1=#{signature}"
15
+ timestamp = Time.now
16
+
17
+ # compute_signature was private until version 5.19.0 when it was made
18
+ # public and had it's API changed to split timestamp to a separate field.
19
+ signer = Stripe::Webhook::Signature.method(:compute_signature)
20
+ signature =
21
+ if signer.arity == 3
22
+ signer.call(timestamp, payload, secret)
23
+ else
24
+ signer.call("#{timestamp.to_i}.#{payload}", secret)
25
+ end
26
+
27
+ "t=#{timestamp.to_i},v1=#{signature}"
19
28
  end
20
29
 
21
30
  def webhook(signature, params)
@@ -123,4 +132,18 @@ describe StripeEvent::WebhookController, type: :controller do
123
132
  expect(response.code).to eq '200'
124
133
  end
125
134
  end
135
+
136
+ context "with multiple signing secrets first of which is nil" do
137
+ before(:each) { StripeEvent.signing_secrets = [nil, secret1, secret2] }
138
+
139
+ it "succeeds with valid signature from first secret" do
140
+ webhook_with_signature charge_succeeded, secret1
141
+ expect(response.code).to eq '200'
142
+ end
143
+
144
+ it "succeeds with valid signature from second secret" do
145
+ webhook_with_signature charge_succeeded, secret2
146
+ expect(response.code).to eq '200'
147
+ end
148
+ end
126
149
  end
data/stripe_event.gemspec CHANGED
@@ -18,12 +18,12 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- Appraisals {spec,gemfiles}/*`.split("\n")
19
19
 
20
20
  s.add_dependency "activesupport", ">= 3.1"
21
- s.add_dependency "stripe", [">= 2.8", "< 6"]
21
+ s.add_dependency "stripe", [">= 2.8", "< 7"]
22
22
 
23
23
  s.add_development_dependency "appraisal"
24
24
  s.add_development_dependency "coveralls"
25
25
  s.add_development_dependency "rails", [">= 3.1"]
26
- s.add_development_dependency "rake", "< 11.0"
26
+ s.add_development_dependency "rake"
27
27
  s.add_development_dependency "rspec-rails", "~> 3.7"
28
28
  s.add_development_dependency "webmock", "~> 1.9"
29
29
  end
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: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Whalen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-23 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '2.8'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '6'
36
+ version: '7'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '2.8'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '6'
46
+ version: '7'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: appraisal
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -90,16 +90,16 @@ dependencies:
90
90
  name: rake
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "<"
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '11.0'
95
+ version: '0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "<"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '11.0'
102
+ version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec-rails
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -134,9 +134,9 @@ executables: []
134
134
  extensions: []
135
135
  extra_rdoc_files: []
136
136
  files:
137
+ - ".github/workflows/ci.yml"
137
138
  - ".gitignore"
138
139
  - ".rspec"
139
- - ".travis.yml"
140
140
  - Appraisals
141
141
  - CHANGELOG.md
142
142
  - CONTRIBUTING.md
@@ -151,10 +151,13 @@ files:
151
151
  - gemfiles/rails5.1.gemfile
152
152
  - gemfiles/rails5.2.gemfile
153
153
  - gemfiles/rails6.0.gemfile
154
+ - gemfiles/rails6.1.gemfile
155
+ - gemfiles/rails7.0.gemfile
154
156
  - gemfiles/rails_master.gemfile
155
157
  - gemfiles/stripe3.gemfile
156
158
  - gemfiles/stripe4.gemfile
157
159
  - gemfiles/stripe5.gemfile
160
+ - gemfiles/stripe6.gemfile
158
161
  - lib/stripe_event.rb
159
162
  - lib/stripe_event/engine.rb
160
163
  - lib/stripe_event/version.rb
@@ -200,7 +203,7 @@ homepage: https://github.com/integrallis/stripe_event
200
203
  licenses:
201
204
  - MIT
202
205
  metadata: {}
203
- post_install_message:
206
+ post_install_message:
204
207
  rdoc_options: []
205
208
  require_paths:
206
209
  - lib
@@ -215,8 +218,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
218
  - !ruby/object:Gem::Version
216
219
  version: '0'
217
220
  requirements: []
218
- rubygems_version: 3.0.3
219
- signing_key:
221
+ rubygems_version: 3.3.12
222
+ signing_key:
220
223
  specification_version: 4
221
224
  summary: Stripe webhook integration for Rails applications.
222
225
  test_files:
@@ -226,10 +229,13 @@ test_files:
226
229
  - gemfiles/rails5.1.gemfile
227
230
  - gemfiles/rails5.2.gemfile
228
231
  - gemfiles/rails6.0.gemfile
232
+ - gemfiles/rails6.1.gemfile
233
+ - gemfiles/rails7.0.gemfile
229
234
  - gemfiles/rails_master.gemfile
230
235
  - gemfiles/stripe3.gemfile
231
236
  - gemfiles/stripe4.gemfile
232
237
  - gemfiles/stripe5.gemfile
238
+ - gemfiles/stripe6.gemfile
233
239
  - spec/controllers/webhook_controller_spec.rb
234
240
  - spec/dummy/README.rdoc
235
241
  - spec/dummy/Rakefile
data/.travis.yml DELETED
@@ -1,39 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- rvm:
5
- - 2.3
6
- - 2.4
7
- - 2.5
8
- - 2.6
9
-
10
- gemfile:
11
- - gemfiles/rails4.2.gemfile
12
- - gemfiles/rails5.1.gemfile
13
- - gemfiles/rails5.2.gemfile
14
- - gemfiles/stripe3.gemfile
15
- - gemfiles/stripe4.gemfile
16
- - gemfiles/stripe5.gemfile
17
-
18
- matrix:
19
- include:
20
- - rvm: 2.3
21
- gemfile: gemfiles/rails3.2.gemfile
22
- - rvm: 2.5
23
- gemfile: gemfiles/rails6.0.gemfile
24
- - rvm: 2.6
25
- gemfile: gemfiles/rails6.0.gemfile
26
- - rvm: 2.6
27
- gemfile: gemfiles/rails_master.gemfile
28
- exclude:
29
- - rvm: 2.5
30
- gemfile: gemfiles/rails4.2.gemfile
31
- - rvm: 2.6
32
- gemfile: gemfiles/rails4.2.gemfile
33
- allow_failures:
34
- - gemfile: gemfiles/rails_master.gemfile
35
- fast_finish: true
36
-
37
- notifications:
38
- email:
39
- - daniel.r.whalen+travis-ci@gmail.com