stripe_event 0.3.0 → 0.3.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.
data/README.md
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
[](http://travis-ci.org/integrallis/stripe_event)
|
4
4
|
|
5
|
-
stripe_event is built on the ActiveSupport::Notifications API. Incoming webhook requests are authenticated by retrieving the event from Stripe.
|
5
|
+
stripe_event is built on the ActiveSupport::Notifications API. Incoming webhook requests are authenticated by retrieving the [event object](https://stripe.com/docs/api?lang=ruby#event_object) from Stripe. Define subscriber blocks to handle one, many, or all event types.
|
6
6
|
|
7
7
|
## Install
|
8
8
|
|
9
|
-
|
10
9
|
```ruby
|
11
10
|
# Gemfile
|
12
11
|
gem 'stripe_event'
|
@@ -14,7 +13,7 @@ gem 'stripe_event'
|
|
14
13
|
|
15
14
|
```ruby
|
16
15
|
# config/routes.rb
|
17
|
-
mount StripeEvent::Engine => "/
|
16
|
+
mount StripeEvent::Engine => "/my-chosen-path" # provide a custom path
|
18
17
|
```
|
19
18
|
|
20
19
|
## Usage
|
@@ -23,8 +22,7 @@ mount StripeEvent::Engine => "/stripe_event" # or provide a custom path
|
|
23
22
|
# config/initializers/stripe.rb
|
24
23
|
Stripe.api_key = ENV['STRIPE_API_KEY'] # Set your api key
|
25
24
|
|
26
|
-
StripeEvent.
|
27
|
-
|
25
|
+
StripeEvent.setup do
|
28
26
|
subscribe 'charge.failed' do |event|
|
29
27
|
MyClass.handle_failed_charge(event) # Define subscriber behavior
|
30
28
|
end
|
@@ -36,7 +34,6 @@ StripeEvent.registration do
|
|
36
34
|
subscribe do |event|
|
37
35
|
# Handle all event types - logging, etc.
|
38
36
|
end
|
39
|
-
|
40
37
|
end
|
41
38
|
```
|
42
39
|
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module StripeEvent
|
2
|
-
class WebhookController <
|
2
|
+
class WebhookController < ActionController::Base
|
3
3
|
def event
|
4
|
-
|
4
|
+
event = Stripe::Event.retrieve(params[:id])
|
5
|
+
StripeEvent.publish(event)
|
5
6
|
head :ok
|
7
|
+
rescue Stripe::StripeError
|
8
|
+
head :unauthorized
|
6
9
|
end
|
7
10
|
end
|
8
11
|
end
|
@@ -7,7 +7,9 @@ module StripeEvent
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def register
|
10
|
-
ActiveSupport::Notifications.subscribe(pattern,
|
10
|
+
ActiveSupport::Notifications.subscribe(pattern) do |*_, payload|
|
11
|
+
@block.call(payload[:event])
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
private
|
@@ -16,12 +18,6 @@ module StripeEvent
|
|
16
18
|
Regexp.union(@names.empty? ? TYPE_LIST : @names)
|
17
19
|
end
|
18
20
|
|
19
|
-
def proxied_block
|
20
|
-
lambda do |name, started, finished, id, payload|
|
21
|
-
@block.call(payload[:event])
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
21
|
def ensure_valid_types!
|
26
22
|
invalid_names = @names.select { |name| !TYPE_LIST.include?(name) }
|
27
23
|
raise InvalidEventType.new(invalid_names) if invalid_names.any?
|
data/lib/stripe_event/version.rb
CHANGED
data/lib/stripe_event.rb
CHANGED
@@ -5,7 +5,12 @@ require "stripe_event/types"
|
|
5
5
|
|
6
6
|
module StripeEvent
|
7
7
|
class << self
|
8
|
-
alias_method :
|
8
|
+
alias_method :setup, :instance_eval
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.registration(&block)
|
12
|
+
warn "[Deprecation Warning] StripeEvent.registration is deprecated. Use StripeEvent.setup."
|
13
|
+
instance_eval(&block)
|
9
14
|
end
|
10
15
|
|
11
16
|
def self.publish(event_obj)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe_event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70103674405340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70103674405340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: stripe
|
27
|
-
requirement: &
|
27
|
+
requirement: &70103674404620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.6'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70103674404620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70103674420300 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.10'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70103674420300
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: webmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &70103674419640 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '1.8'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70103674419640
|
58
58
|
description: Stripe webhook integration for Rails applications.
|
59
59
|
email:
|
60
60
|
- dwhalen@integrallis.com
|
@@ -62,7 +62,6 @@ executables: []
|
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
|
-
- app/controllers/stripe_event/application_controller.rb
|
66
65
|
- app/controllers/stripe_event/webhook_controller.rb
|
67
66
|
- config/routes.rb
|
68
67
|
- lib/stripe_event/engine.rb
|