stripe-rails 1.2.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b4472dc93a9a92f24f317a0d1048126780e7bf84
4
- data.tar.gz: 862d7edf59f3ba3c8e1288a93ef892805b70155a
2
+ SHA256:
3
+ metadata.gz: 527a4386b9b19687aa3a803c8645a814d7f9c5e2ece5a51033a453eafcceab58
4
+ data.tar.gz: 5fd3c8566a15edbf6319658a3adbca642dbba53882bab207732c3dc946533edd
5
5
  SHA512:
6
- metadata.gz: 829dc5a3512ab65c93d82fdff3b761631d1119c0e48e70d46aa793530e6e2d3914c17ea30986cca4ddf58928572e6a5cea0b89a7af96e2a4171c51930bf15b51
7
- data.tar.gz: 7f0f08f7bc250f8ee65cbf8c68b13226e1f28505c831af66c247c2d6436865953eb763788eba33db1a8cc8fcbc874de55b94b56a820a4345ccadd2d4e4ec0c95
6
+ metadata.gz: 748847a11c9e7e9741b6da139fea408ee6a95f3768f8bc8c35ae4f64dad843661e317502c7d898754d309dc34797cdffa5d0ab5f6151e50a8402ce13f5fcda91
7
+ data.tar.gz: fdd425809e6d4522f752c949c1eab0546524cd255ff97b6591b6a86bd962d14cdab2a7cde6c42573e1dce17eae1fbffd7f672473adc77a3c4cb5825ba8692217
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ test/dummy/**/*.log
19
19
  tmp
20
20
  .rvmrc
21
21
  .DS_Store
22
+ .ruby-version
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.5.0
3
4
  - 2.4.1
4
5
  - 2.3.4
5
6
  - 2.2.7
data/Changelog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.2.1 (2018-03-22)
2
+
3
+ * Fixes Stripe API update on 2018-02-05 that breaks the plan builder (thanks to @georgecheng for reporting this!)
4
+
1
5
  ## 1.2.0 (2018-01-02)
2
6
 
3
7
  * Added additional callbacks (thanks @lloydpick & @dja)
data/Gemfile CHANGED
@@ -9,6 +9,10 @@ gem 'tzinfo'
9
9
  gem 'mocha'
10
10
  gem 'pry'
11
11
 
12
+ group :development, :test do
13
+ gem 'm'
14
+ end
15
+
12
16
  group :test do
13
17
  gem 'simplecov', require: false
14
18
  # NOTE: tracking master temporarily until they
@@ -17,4 +21,5 @@ group :test do
17
21
  gem 'poltergeist' # required for system tests
18
22
  gem 'phantomjs' # ditto
19
23
  gem 'puma' # ditto
24
+ gem 'webmock'
20
25
  end
@@ -16,4 +16,5 @@ group :test do
16
16
  gem 'poltergeist'
17
17
  gem 'phantomjs', :require => 'phantomjs/poltergeist'
18
18
  gem 'puma'
19
+ gem 'webmock'
19
20
  end
@@ -16,4 +16,5 @@ group :test do
16
16
  gem 'poltergeist'
17
17
  gem 'phantomjs', :require => 'phantomjs/poltergeist'
18
18
  gem 'puma'
19
+ gem 'webmock'
19
20
  end
data/lib/stripe/plans.rb CHANGED
@@ -20,7 +20,43 @@ module Stripe
20
20
  @trial_period_days = 0
21
21
  end
22
22
 
23
+ private
24
+
23
25
  def create_options
26
+ if api_version_after_switch_to_products_in_plans
27
+ default_create_options
28
+ else
29
+ create_options_without_products
30
+ end
31
+ end
32
+
33
+ def api_version_after_switch_to_products_in_plans
34
+ Date.parse(current_api_version) >= Date.parse('2018-02-05')
35
+ end
36
+
37
+ def current_api_version
38
+ Stripe.api_version || begin
39
+ resp, _ = @stripe_class.request(:get, @stripe_class.resource_url)
40
+ resp.http_headers['stripe-version']
41
+ end
42
+ end
43
+
44
+ def default_create_options
45
+ {
46
+ :currency => @currency,
47
+ product: {
48
+ :name => @name,
49
+ :statement_descriptor => @statement_descriptor,
50
+ },
51
+ :amount => @amount,
52
+ :interval => @interval,
53
+ :interval_count => @interval_count,
54
+ :trial_period_days => @trial_period_days,
55
+ :metadata => @metadata,
56
+ }
57
+ end
58
+
59
+ def create_options_without_products
24
60
  {
25
61
  :currency => @currency,
26
62
  :name => @name,
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module Rails
3
- VERSION = '1.2.0'
3
+ VERSION = '1.2.1'
4
4
  end
5
5
  end
data/stripe-rails.gemspec CHANGED
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Stripe::Rails::VERSION
17
17
  gem.add_dependency 'rails', '>= 3'
18
- gem.add_dependency 'stripe'
18
+ gem.add_dependency 'stripe', '>= 1.36.2'
19
19
  gem.add_dependency 'responders'
20
20
  end
@@ -0,0 +1,7 @@
1
+ {
2
+ "object": "list",
3
+ "count": 0,
4
+ "data": [],
5
+ "has_more": false,
6
+ "url": "/v1/plans"
7
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "Server": "nginx",
3
+ "Date": "Wed, 21 Mar 2018 20:04:56 GMT",
4
+ "Content-Type": "application/json",
5
+ "Content-Length": "5807",
6
+ "Connection": "close",
7
+ "Access-Control-Allow-Credentials": "true",
8
+ "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE",
9
+ "Access-Control-Allow-Origin": "*",
10
+ "Access-Control-Expose-Headers": "Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required",
11
+ "Access-Control-Max-Age": "300",
12
+ "Cache-Control": "no-cache, no-store",
13
+ "Request-Id": "req_UCuedZo4sKqUXn",
14
+ "Stripe-Version": "2018-02-05",
15
+ "Strict-Transport-Security": "max-age=31556926; includeSubDomains; preload"
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "Server": "nginx",
3
+ "Date": "Wed, 21 Mar 2018 20:04:56 GMT",
4
+ "Content-Type": "application/json",
5
+ "Content-Length": "5807",
6
+ "Connection": "close",
7
+ "Access-Control-Allow-Credentials": "true",
8
+ "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE",
9
+ "Access-Control-Allow-Origin": "*",
10
+ "Access-Control-Expose-Headers": "Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required",
11
+ "Access-Control-Max-Age": "300",
12
+ "Cache-Control": "no-cache, no-store",
13
+ "Request-Id": "req_UCuedZo4sKqUXn",
14
+ "Stripe-Version": "2017-02-05",
15
+ "Strict-Transport-Security": "max-age=31556926; includeSubDomains; preload"
16
+ }
@@ -104,9 +104,16 @@ describe 'building plans' do
104
104
  end
105
105
 
106
106
  describe 'uploading' do
107
+ include FixtureLoader
108
+
107
109
  describe 'when none exists on stripe.com' do
110
+ let(:headers) { load_request_fixture('stripe_plans_headers_2017.json') }
108
111
  before do
109
112
  Stripe::Plan.stubs(:retrieve).raises(Stripe::InvalidRequestError.new("not found", "id"))
113
+
114
+ stub_request(:get, "https://api.stripe.com/v1/plans").
115
+ with(headers: { 'Authorization'=>'Bearer XYZ',}).
116
+ to_return(status: 200, body: load_request_fixture('stripe_plans.json'), headers: JSON.parse(headers))
110
117
  end
111
118
 
112
119
  it 'creates the plan online' do
@@ -139,6 +146,51 @@ describe 'building plans' do
139
146
  Stripe::Plans::ALTERNATIVE_CURRENCY.put!
140
147
  end
141
148
 
149
+ describe 'when using the API version that supports products' do
150
+ before { Stripe.api_version = '2018-02-05' }
151
+ after { Stripe.api_version = nil }
152
+
153
+ it 'creates the plan online' do
154
+ Stripe::Plan.expects(:create).with(
155
+ :id => :gold,
156
+ :currency => 'usd',
157
+ :product => {
158
+ :name => 'Solid Gold',
159
+ :statement_descriptor => nil,
160
+ },
161
+ :amount => 699,
162
+ :interval => 'month',
163
+ :interval_count => 1,
164
+ :trial_period_days => 0,
165
+ :metadata => nil,
166
+ )
167
+ Stripe::Plans::GOLD.put!
168
+ end
169
+ end
170
+
171
+ describe 'when api_version is not set for api versions that support products' do
172
+ before { Stripe.api_version = nil }
173
+ subject { Stripe::Plans::GOLD.put! }
174
+ let(:headers) { load_request_fixture('stripe_plans_headers.json') }
175
+
176
+ it 'creates the plan online' do
177
+ Stripe::Plan.expects(:create).with(
178
+ :id => :gold,
179
+ :currency => 'usd',
180
+ :product => {
181
+ :name => 'Solid Gold',
182
+ :statement_descriptor => nil,
183
+ },
184
+ :amount => 699,
185
+ :interval => 'month',
186
+ :interval_count => 1,
187
+ :trial_period_days => 0,
188
+ :metadata => nil,
189
+ )
190
+
191
+ subject
192
+ end
193
+ end
142
194
  end
143
195
 
144
196
  describe 'when it is already present on stripe.com' do
data/test/spec_helper.rb CHANGED
@@ -5,6 +5,9 @@ end
5
5
 
6
6
  require 'minitest/autorun'
7
7
 
8
+ require 'webmock/minitest'
9
+ WebMock.disable_net_connect!(allow_localhost: true)
10
+
8
11
  # Configure Rails Environment
9
12
  ENV["RAILS_ENV"] = "test"
10
13
  ENV['STRIPE_SECRET_KEY'] = 'XYZ'
@@ -11,6 +11,12 @@ describe "Configuring the stripe engine" do
11
11
 
12
12
  def rerun_initializers!; initializers.each{|init| init.run(app) }; end
13
13
 
14
+ after do
15
+ Stripe.api_version = nil
16
+ Stripe.api_base = 'https://api.stripe.com'
17
+ Stripe.api_key = 'XYZ'
18
+ end
19
+
14
20
  describe 'Stripe configurations' do
15
21
  it "will have valid default values" do
16
22
  Stripe.api_base.must_equal 'https://api.stripe.com'
@@ -0,0 +1,5 @@
1
+ module FixtureLoader
2
+ def load_request_fixture(name)
3
+ Pathname.new(__FILE__).join('..', '..', 'fixtures', name).read
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-01-02 00:00:00.000000000 Z
13
+ date: 2018-03-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '0'
35
+ version: 1.36.2
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '0'
42
+ version: 1.36.2
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: responders
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +140,9 @@ files:
140
140
  - test/dummy_apis_controller_spec.rb
141
141
  - test/dummy_stripes_controller_spec.rb
142
142
  - test/event.json
143
+ - test/fixtures/stripe_plans.json
144
+ - test/fixtures/stripe_plans_headers.json
145
+ - test/fixtures/stripe_plans_headers_2017.json
143
146
  - test/invoice.json
144
147
  - test/javascript_helper_spec.rb
145
148
  - test/pings_controller_spec.rb
@@ -148,6 +151,7 @@ files:
148
151
  - test/stripe_initializers_spec.rb
149
152
  - test/support/application_system_test_case.rb
150
153
  - test/support/callback_helpers.rb
154
+ - test/support/fixture_loader.rb
151
155
  - test/support/null_system_test_case.rb
152
156
  - test/testing_spec.rb
153
157
  homepage: https://github.com/Everapps/stripe-rails
@@ -170,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
174
  version: '0'
171
175
  requirements: []
172
176
  rubyforge_project:
173
- rubygems_version: 2.6.13
177
+ rubygems_version: 2.7.3
174
178
  signing_key:
175
179
  specification_version: 4
176
180
  summary: A gem to integrate stripe into your rails app
@@ -219,6 +223,9 @@ test_files:
219
223
  - test/dummy_apis_controller_spec.rb
220
224
  - test/dummy_stripes_controller_spec.rb
221
225
  - test/event.json
226
+ - test/fixtures/stripe_plans.json
227
+ - test/fixtures/stripe_plans_headers.json
228
+ - test/fixtures/stripe_plans_headers_2017.json
222
229
  - test/invoice.json
223
230
  - test/javascript_helper_spec.rb
224
231
  - test/pings_controller_spec.rb
@@ -227,5 +234,6 @@ test_files:
227
234
  - test/stripe_initializers_spec.rb
228
235
  - test/support/application_system_test_case.rb
229
236
  - test/support/callback_helpers.rb
237
+ - test/support/fixture_loader.rb
230
238
  - test/support/null_system_test_case.rb
231
239
  - test/testing_spec.rb