stripe-rails 0.3.1 → 0.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
  SHA1:
3
- metadata.gz: 2093ec1a3bd46eb90811710db16bdfe309312e1c
4
- data.tar.gz: 4b3f402cf1327a22688bd5bf6b6cd051be1d23f0
3
+ metadata.gz: cf523c4372b35910caae685adc46a1dd3b1d5ca2
4
+ data.tar.gz: e0f4eed537157fd9076bfb1348e6844d1b2f43a6
5
5
  SHA512:
6
- metadata.gz: 98d339c9a0a0f858af220470bc722c39fc23707dd9a786a9fbc0788cfbb0b0ff71258d6c6b5b31f4b807493da274d63485d15e12083c6ec1357eb3693bb94f3e
7
- data.tar.gz: ee4d0b67c1932dbdc05f287f0502d5ff7a49e7bc3497187c9c8f18642703316a6407ad51533cbcf6d49868f834790d7de3166752b8db44cb1eb37916a635ad23
6
+ metadata.gz: 554e570b3c5bc128e69b66f5ea0ca18865df88d9d72d1ca80c4dbf559d63584d72d125a503821c13c9ba39c5663583da34a52a1b676ec2dec8607ede586e6662
7
+ data.tar.gz: f19160a1340d2b3c0681f9fbd597ed7aa9656addce661526f919ca7188c69c9a0620083033f89685967706572d19612cd6da0afe322332dfaeb2f1a6ed4d68b4
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 1.9.3
3
+ - 2.3.3
5
4
  notifications:
6
5
  email:
7
6
  recipients:
@@ -0,0 +1,50 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This Code of Conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at code-of-conduct@frontside.io. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+
45
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
46
+ version 1.3.0, available at
47
+ [http://contributor-covenant.org/version/1/3/0/][version]
48
+
49
+ [homepage]: http://contributor-covenant.org
50
+ [version]: http://contributor-covenant.org/version/1/3/0/
@@ -1,3 +1,10 @@
1
+ ## 0.4.0 (2017-05-24)
2
+ * Support alternate versions of stripe js
3
+
4
+ ## 0.3.2 (2017-03-06)
5
+ * add `responders` gem as dependency to support `respond_to` method
6
+ * fix unit tests with Rails 4.2 and Rails 5.0
7
+
1
8
  ## 0.3.1 (2014-08-07)
2
9
  * add `eager_load` option to load callbacks into classes in non-eager-loaded enviroments
3
10
 
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ gem "rake"
8
8
  gem 'tzinfo'
9
9
  gem 'mocha'
10
10
  gem 'pry'
11
+ gem 'responders', '~> 2.0' # to support Rails 4.2
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2013 The Frontside Software, Inc.
1
+ Copyright (c) 2012-2017 The Frontside Software, Inc.
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -26,22 +26,31 @@ stripe-rails provides a helper to make this easy:
26
26
  ```erb
27
27
  <%= stripe_javascript_tag %>
28
28
  ```
29
+
29
30
  or, you can render it as a partial:
30
31
 
31
32
  ```erb
32
33
  <%= render :partial => 'stripe/js' %>
33
34
  ```
35
+
34
36
  In both cases, stripe-rails will choose a version of stripe.js appropriate for your
35
37
  development environment and automatically configure it to use
36
38
  your publishable API key. By default it uses `stripe-debug.js` for your `development`
37
39
  environment and `stripe.js` for everything else, but you can manually configure it
38
- per environment
40
+ per environment.
39
41
 
40
42
  ```ruby
41
43
  config.stripe.debug_js = true # use stripe-debug.js
42
44
  config.stripe.debug_js = false # use stripe.js
43
45
  ```
44
46
 
47
+ By default the helper renders the `v1` version of `stripe.js`. You can provide an
48
+ alternate version to the helper to generate the appropriate tag:
49
+
50
+ ```erb
51
+ <%= stripe_javascript_tag(:v3) %>
52
+ ```
53
+
45
54
  ### Setup your API keys.
46
55
 
47
56
  You will need to configure your application to authenticate with stripe.com
@@ -73,7 +82,7 @@ rake stripe:verify
73
82
  ```
74
83
 
75
84
  If you are going to be using stripe.js, then you will also need to set the value of your
76
- publishiable key. A nice way to do it is to set your test publishable for all environments:
85
+ publishable key. A nice way to do it is to set your test publishable for all environments:
77
86
 
78
87
  ```ruby
79
88
  # config/application.rb
@@ -159,7 +168,7 @@ NOTE: You must destroy plans manually from your stripe dashboard.
159
168
  ## Webhooks
160
169
 
161
170
  Stripe::Rails automatically sets up your application to receive webhooks from stripe.com whenever
162
- an payment event is generated. To enable this, you will need to configure your [stripe webhooks][3] to
171
+ a payment event is generated. To enable this, you will need to configure your [stripe webhooks][3] to
163
172
  point back to your application. By default, the webhook controller is mounted at '/stripe/events' so
164
173
  you would want to enter in `http://myproductionapp.com/stripe/events` as your url for live mode,
165
174
  and `http://mystagingapp.com/stripe/events` for your test mode.
@@ -232,7 +241,7 @@ class InvoiceMailer < ActionMailer::Base
232
241
  end
233
242
  ```
234
243
 
235
- **Note:** `Stripe::Callbacks` won't get included until the including class has been loaded. This is usually not an issue in the production environment as eager loading is enabled by default (`config.eager_load = true`). You may run into an issue in your development environment where eager loading is disabled by default.
244
+ **Note:** `Stripe::Callbacks` won't get included until the including class has been loaded. This is usually not an issue in the production environment as eager loading is enabled by default (`config.eager_load = true`). You may run into an issue in your development environment where eager loading is disabled by default.
236
245
 
237
246
  If you don't wish to enable eager loading in development, you can configure the classes to be eager loaded like so
238
247
 
@@ -240,7 +249,7 @@ If you don't wish to enable eager loading in development, you can configure the
240
249
  # in your application's config/environments/development.rb
241
250
  config.stripe.eager_load = 'account', 'module/some_class', 'etc'
242
251
  ```
243
- This will ensure that callbacks will get loaded in those configured classes if eager loading is disabled.
252
+ This will ensure that callbacks will get loaded in those configured classes if eager loading is disabled.
244
253
 
245
254
  The naming convention for the callback events is after__{callback_name}! where `callback_name`
246
255
  is name of the stripe event with all `.` characters substituted with underscores. So, for
@@ -351,7 +360,14 @@ needs, including integration with stripe.com.
351
360
  [4]: https://stripe.com/docs/api?lang=ruby#events
352
361
  [5]: https://stripe.com/docs/api?lang=ruby#event_types
353
362
  [6]: https://stripe.com/docs/webhooks
354
- [7]: http://thefrontside.net
363
+ [7]: http://frontside.io
355
364
  [8]: https://stripe.com/docs/api?lang=ruby#customers
356
365
  [9]: https://stripe.com/docs/api?lang=ruby#invoices
357
366
  [10]: https://stripe.com/docs/api?lang=ruby#charges
367
+
368
+
369
+ ## Code of Conduct
370
+ Please note that this project is released with a Contributor Code of
371
+ Conduct. By participating in this project you agree to abide by its
372
+ terms, which can be found in the `CODE_OF_CONDUCT.md` file in this
373
+ repository.
@@ -1,7 +1,9 @@
1
1
  module Stripe
2
2
  module JavascriptHelper
3
- def stripe_javascript_tag
4
- render :partial => 'stripe/js'
3
+ def stripe_javascript_tag(stripe_js_version = 'v1')
4
+ stripe_js_version = stripe_js_version.to_s.downcase
5
+
6
+ render 'stripe/js', stripe_js_version: stripe_js_version
5
7
  end
6
8
  end
7
9
  end
@@ -1,8 +1,13 @@
1
- <% if Rails.application.config.stripe.debug_js %>
2
- <script type="text/javascript" src="https://js.stripe.com/v1/stripe-debug.js"></script>
3
- <% else %>
4
- <script type="text/javascript" src="https://js.stripe.com/v1/"></script>
5
- <% end %>
1
+ <%- case (stripe_js_version || 'v1') %>
2
+ <%- when 'v1', 'v2' %>
3
+ <%- if ::Rails.application.config.stripe.debug_js %>
4
+ <script type="text/javascript" src="https://js.stripe.com/<%=stripe_js_version%>/stripe-debug.js"></script>
5
+ <%- else %>
6
+ <script type="text/javascript" src="https://js.stripe.com/<%=stripe_js_version%>/"></script>
7
+ <%- end %>
8
+ <%- when 'v3' # the debug js for v3 isn't available %>
9
+ <script type="text/javascript" src="https://js.stripe.com/<%=stripe_js_version%>/"></script>
10
+ <%- end %>
6
11
  <script type="text/javascript">
7
12
  Stripe.setPublishableKey("<%= Rails.application.config.stripe.publishable_key or fail 'No stripe.com publishable key found. Please set config.stripe.publishable_key in config/application.rb to one of your publishable keys, which can be found here: https://manage.stripe.com/#account/apikeys' %>")
8
13
  </script>
@@ -42,8 +42,9 @@ module Stripe
42
42
  when Array, Set
43
43
  stringified_keys = only.map(&:to_s)
44
44
  proc do |target, evt|
45
- intersection = evt.data.previous_attributes.keys - stringified_keys
46
- block.call(target, evt) if intersection != evt.data.previous_attributes.keys
45
+ stringified_previous_attributes_keys = evt.data.previous_attributes.keys.map(&:to_s)
46
+ intersection = stringified_previous_attributes_keys - stringified_keys
47
+ block.call(target, evt) if intersection != stringified_previous_attributes_keys
47
48
  end
48
49
  when nil
49
50
  block
@@ -3,7 +3,7 @@ module Stripe
3
3
  include ConfigurationBuilder
4
4
 
5
5
  configuration_for :plan do
6
- attr_accessor :name, :amount, :interval, :interval_count, :trial_period_days, :currency
6
+ attr_accessor :name, :amount, :interval, :interval_count, :trial_period_days, :currency, :metadata
7
7
 
8
8
  validates_presence_of :id, :name, :amount
9
9
  validates_inclusion_of :interval, :in => %w(week month year), :message => "'%{value}' is not one of 'week', 'month' or 'year'"
@@ -22,7 +22,8 @@ module Stripe
22
22
  :amount => @amount,
23
23
  :interval => @interval,
24
24
  :interval_count => @interval_count,
25
- :trial_period_days => @trial_period_days
25
+ :trial_period_days => @trial_period_days,
26
+ :metadata => @metadata
26
27
  }
27
28
  end
28
29
  end
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module Rails
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -2,11 +2,12 @@
2
2
  require File.expand_path('../lib/stripe/rails/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["rubygeek"]
6
- gem.email = ["nola@rubygeek.com"]
5
+ gem.authors = ["Charles Lowell", "Nola Stowe"]
6
+ gem.email = ["cowboyd@frontside.io"]
7
7
  gem.description = "A gem to integrate stripe into your rails app"
8
8
  gem.summary = "A gem to integrate stripe into your rails app"
9
- gem.homepage = ""
9
+ gem.homepage = "https://github.com/Everapps/stripe-rails"
10
+ gem.license = 'MIT'
10
11
 
11
12
  gem.files = `git ls-files`.split($\)
12
13
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -15,5 +16,6 @@ Gem::Specification.new do |gem|
15
16
  gem.require_paths = ["lib"]
16
17
  gem.version = Stripe::Rails::VERSION
17
18
  gem.add_dependency 'rails', '>= 3'
18
- gem.add_dependency 'stripe'
19
+ gem.add_dependency 'stripe', '< 2'
20
+ gem.add_dependency 'responders', '~> 2.0'
19
21
  end
@@ -156,7 +156,7 @@ describe Stripe::Callbacks do
156
156
  describe 'specified as a lambda' do
157
157
  before do
158
158
  @observer.class_eval do
159
- after_invoice_updated :only => proc {|target, evt| evt.data.previous_attributes.has_key? "closed"} do |i,e|
159
+ after_invoice_updated :only => proc {|target, evt| evt.data.previous_attributes.to_hash.has_key? :closed} do |i,e|
160
160
  events << e
161
161
  end
162
162
  end
@@ -14,7 +14,6 @@ Dummy::Application.configure do
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance
16
16
  config.serve_static_assets = true
17
- config.static_cache_control = "public, max-age=3600"
18
17
 
19
18
  # Show full error reports and disable caching
20
19
  config.consider_all_requests_local = true
@@ -0,0 +1,39 @@
1
+ require 'minitest/autorun'
2
+ require 'spec_helper'
3
+
4
+ describe Stripe::JavascriptHelper do
5
+ before do
6
+ Rails.application.config.stripe.publishable_key = 'pub_xxxx'
7
+
8
+ @controller = ActionView::TestCase::TestController.new
9
+ @view = @controller.view_context
10
+ @view.singleton_class.include(Stripe::JavascriptHelper)
11
+ end
12
+
13
+ describe '#stripe_javascript_tag' do
14
+ describe 'when no options are passed' do
15
+ it 'should default to v1' do
16
+ @view.stripe_javascript_tag.must_include 'https://js.stripe.com/v1/'
17
+ end
18
+ end
19
+
20
+ describe 'when the v3 option is passed' do
21
+ it 'should default to v3' do
22
+ @view.stripe_javascript_tag(:v3).must_include 'https://js.stripe.com/v3/'
23
+ end
24
+ end
25
+
26
+ describe 'when the debug flag is enabled' do
27
+ before { Rails.application.config.stripe.debug_js = true }
28
+ it 'should render the debug js' do
29
+ @view.stripe_javascript_tag.must_include 'https://js.stripe.com/v1/stripe-debug.js'
30
+ end
31
+
32
+ describe 'when v3 is selected' do
33
+ it 'should not render debug js' do
34
+ @view.stripe_javascript_tag(:v3).wont_include 'https://js.stripe.com/v1/stripe-debug.js'
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -10,6 +10,7 @@ describe 'building plans' do
10
10
  plan.interval = 'month'
11
11
  plan.interval_count = 3
12
12
  plan.trial_period_days = 30
13
+ plan.metadata = {:number_of_awesome_things => 5}
13
14
  end
14
15
  end
15
16
  after do
@@ -83,7 +84,8 @@ describe 'building plans' do
83
84
  :amount => 699,
84
85
  :interval => 'month',
85
86
  :interval_count => 1,
86
- :trial_period_days => 0
87
+ :trial_period_days => 0,
88
+ :metadata => nil
87
89
  )
88
90
  Stripe::Plans::GOLD.put!
89
91
  end
@@ -96,7 +98,8 @@ describe 'building plans' do
96
98
  :amount => 699,
97
99
  :interval => 'month',
98
100
  :interval_count => 1,
99
- :trial_period_days => 0
101
+ :trial_period_days => 0,
102
+ :metadata => nil
100
103
  )
101
104
  Stripe::Plans::ALTERNATIVE_CURRENCY.put!
102
105
  end
metadata CHANGED
@@ -1,52 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - rubygeek
7
+ - Charles Lowell
8
+ - Nola Stowe
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
12
+ date: 2017-05-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - '>='
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
20
  version: '3'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - '>='
25
+ - - ">="
25
26
  - !ruby/object:Gem::Version
26
27
  version: '3'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: stripe
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - '>='
32
+ - - "<"
32
33
  - !ruby/object:Gem::Version
33
- version: '0'
34
+ version: '2'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - '>='
39
+ - - "<"
39
40
  - !ruby/object:Gem::Version
40
- version: '0'
41
+ version: '2'
42
+ - !ruby/object:Gem::Dependency
43
+ name: responders
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.0'
41
56
  description: A gem to integrate stripe into your rails app
42
57
  email:
43
- - nola@rubygeek.com
58
+ - cowboyd@frontside.io
44
59
  executables: []
45
60
  extensions: []
46
61
  extra_rdoc_files: []
47
62
  files:
48
- - .gitignore
49
- - .travis.yml
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
50
66
  - Changelog.md
51
67
  - Gemfile
52
68
  - LICENSE
@@ -74,7 +90,6 @@ files:
74
90
  - lib/stripe/rails/tasks.rake
75
91
  - lib/stripe/rails/version.rb
76
92
  - stripe-rails.gemspec
77
- - test/.DS_Store
78
93
  - test/all.rb
79
94
  - test/callbacks_spec.rb
80
95
  - test/coupon_builder_spec.rb
@@ -114,11 +129,13 @@ files:
114
129
  - test/dummy/public/favicon.ico
115
130
  - test/dummy/script/rails
116
131
  - test/invoice_payment_succeeded.json
132
+ - test/javascript_helper_spec.rb
117
133
  - test/plan_builder_spec.rb
118
134
  - test/spec_helper.rb
119
135
  - test/stripe_rails_spec.rb
120
- homepage: ''
121
- licenses: []
136
+ homepage: https://github.com/Everapps/stripe-rails
137
+ licenses:
138
+ - MIT
122
139
  metadata: {}
123
140
  post_install_message:
124
141
  rdoc_options: []
@@ -126,22 +143,21 @@ require_paths:
126
143
  - lib
127
144
  required_ruby_version: !ruby/object:Gem::Requirement
128
145
  requirements:
129
- - - '>='
146
+ - - ">="
130
147
  - !ruby/object:Gem::Version
131
148
  version: '0'
132
149
  required_rubygems_version: !ruby/object:Gem::Requirement
133
150
  requirements:
134
- - - '>='
151
+ - - ">="
135
152
  - !ruby/object:Gem::Version
136
153
  version: '0'
137
154
  requirements: []
138
155
  rubyforge_project:
139
- rubygems_version: 2.0.3
156
+ rubygems_version: 2.5.2
140
157
  signing_key:
141
158
  specification_version: 4
142
159
  summary: A gem to integrate stripe into your rails app
143
160
  test_files:
144
- - test/.DS_Store
145
161
  - test/all.rb
146
162
  - test/callbacks_spec.rb
147
163
  - test/coupon_builder_spec.rb
@@ -181,6 +197,7 @@ test_files:
181
197
  - test/dummy/public/favicon.ico
182
198
  - test/dummy/script/rails
183
199
  - test/invoice_payment_succeeded.json
200
+ - test/javascript_helper_spec.rb
184
201
  - test/plan_builder_spec.rb
185
202
  - test/spec_helper.rb
186
203
  - test/stripe_rails_spec.rb