stripe-rails 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Changelog.md +4 -0
- data/Gemfile +5 -0
- data/gemfiles/rails4.gemfile +1 -0
- data/gemfiles/rails5.gemfile +1 -0
- data/lib/stripe/plans.rb +36 -0
- data/lib/stripe/rails/version.rb +1 -1
- data/stripe-rails.gemspec +1 -1
- data/test/fixtures/stripe_plans.json +7 -0
- data/test/fixtures/stripe_plans_headers.json +16 -0
- data/test/fixtures/stripe_plans_headers_2017.json +16 -0
- data/test/plan_builder_spec.rb +52 -0
- data/test/spec_helper.rb +3 -0
- data/test/stripe_initializers_spec.rb +6 -0
- data/test/support/fixture_loader.rb +5 -0
- metadata +13 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 527a4386b9b19687aa3a803c8645a814d7f9c5e2ece5a51033a453eafcceab58
|
4
|
+
data.tar.gz: 5fd3c8566a15edbf6319658a3adbca642dbba53882bab207732c3dc946533edd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 748847a11c9e7e9741b6da139fea408ee6a95f3768f8bc8c35ae4f64dad843661e317502c7d898754d309dc34797cdffa5d0ab5f6151e50a8402ce13f5fcda91
|
7
|
+
data.tar.gz: fdd425809e6d4522f752c949c1eab0546524cd255ff97b6591b6a86bd962d14cdab2a7cde6c42573e1dce17eae1fbffd7f672473adc77a3c4cb5825ba8692217
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
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
|
data/gemfiles/rails4.gemfile
CHANGED
data/gemfiles/rails5.gemfile
CHANGED
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,
|
data/lib/stripe/rails/version.rb
CHANGED
data/stripe-rails.gemspec
CHANGED
@@ -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
|
+
}
|
data/test/plan_builder_spec.rb
CHANGED
@@ -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
@@ -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'
|
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.
|
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-
|
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:
|
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:
|
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.
|
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
|