stripe 1.29.1 → 1.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +9 -5
- data/lib/stripe/account.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +1 -1
- data/lib/stripe/api_operations/update.rb +2 -2
- data/lib/stripe/api_resource.rb +1 -1
- data/lib/stripe/application_fee.rb +1 -1
- data/lib/stripe/charge.rb +6 -6
- data/lib/stripe/customer.rb +4 -4
- data/lib/stripe/dispute.rb +1 -1
- data/lib/stripe/invoice.rb +1 -1
- data/lib/stripe/order.rb +1 -1
- data/lib/stripe/stripe_object.rb +79 -31
- data/lib/stripe/subscription.rb +1 -1
- data/lib/stripe/transfer.rb +1 -1
- data/lib/stripe/util.rb +26 -3
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_test.rb +1 -1
- data/test/stripe/api_resource_test.rb +1 -1
- data/test/stripe/metadata_test.rb +2 -2
- data/test/stripe/stripe_object_test.rb +29 -3
- data/test/stripe/util_test.rb +43 -2
- data/test/stripe_test.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 061c68a3e8fbf7b2adfa0a93489b1b124b08cb37
|
4
|
+
data.tar.gz: 4fda58089700ad1f39ab8a084b09982679b4e9a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2f3f7dff2c30038b9608f825f542061eccb6461bb1c0a9bebfb754ac5d7031c00e4df16e0a753edf92c5934435dcd1bfe191dfd2bdd5744c67ffdc268f3e16c
|
7
|
+
data.tar.gz: b68dfc54c11b18e6081a5794c89d717812607f334c60744f7b0cf0ba2a65a337f8f0465c4e092471cb3709e30df8fc62267550b73d255857914b40c1d9f32c47
|
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 1.30.0 2015-10-09
|
2
|
+
|
3
|
+
* Add `StripeObject#deleted?` for a reliable way to check whether an object is alive
|
4
|
+
* Deprecate `StripeObject#refresh_from`
|
5
|
+
* New parameter encoding scheme that doesn't use `URI.escape`
|
6
|
+
|
1
7
|
=== 1.29.1 2015-10-06
|
2
8
|
|
3
9
|
* Fix bug where ampersands were not being properly encoded
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.30.0
|
data/lib/stripe.rb
CHANGED
@@ -64,6 +64,7 @@ require 'stripe/errors/rate_limit_error'
|
|
64
64
|
|
65
65
|
module Stripe
|
66
66
|
DEFAULT_CA_BUNDLE_PATH = File.dirname(__FILE__) + '/data/ca-certificates.crt'
|
67
|
+
|
67
68
|
@api_base = 'https://api.stripe.com'
|
68
69
|
@connect_base = 'https://connect.stripe.com'
|
69
70
|
@uploads_base = 'https://uploads.stripe.com'
|
@@ -120,13 +121,13 @@ module Stripe
|
|
120
121
|
case method.to_s.downcase.to_sym
|
121
122
|
when :get, :head, :delete
|
122
123
|
# Make params into GET parameters
|
123
|
-
url += "#{URI.parse(url).query ? '&' : '?'}#{
|
124
|
+
url += "#{URI.parse(url).query ? '&' : '?'}#{Util.encode_parameters(params)}" if params && params.any?
|
124
125
|
payload = nil
|
125
126
|
else
|
126
127
|
if headers[:content_type] && headers[:content_type] == "multipart/form-data"
|
127
128
|
payload = params
|
128
129
|
else
|
129
|
-
payload =
|
130
|
+
payload = Util.encode_parameters(params)
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
@@ -205,10 +206,13 @@ module Stripe
|
|
205
206
|
"uname lookup failed"
|
206
207
|
end
|
207
208
|
|
208
|
-
|
209
|
+
# DEPRECATED. Use `Util#encode_parameters` instead.
|
209
210
|
def self.uri_encode(params)
|
210
|
-
Util.
|
211
|
-
|
211
|
+
Util.encode_parameters(params)
|
212
|
+
end
|
213
|
+
class << self
|
214
|
+
extend Gem::Deprecate
|
215
|
+
deprecate :uri_encode, "Stripe::Util#encode_parameters", 2016, 01
|
212
216
|
end
|
213
217
|
|
214
218
|
def self.request_headers(api_key)
|
data/lib/stripe/account.rb
CHANGED
@@ -36,7 +36,7 @@ module Stripe
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def legal_entity=(_)
|
39
|
-
raise NoMethodError.new('Overridding legal_entity can cause
|
39
|
+
raise NoMethodError.new('Overridding legal_entity can cause serious issues. Instead, set the individual fields of legal_entity like blah.legal_entity.first_name = \'Blah\'')
|
40
40
|
end
|
41
41
|
|
42
42
|
def deauthorize(client_id, opts={})
|
@@ -20,7 +20,7 @@ module Stripe
|
|
20
20
|
# We started unintentionally (sort of) allowing attributes send to
|
21
21
|
# +save+ to override values used during the update. So as not to break
|
22
22
|
# the API, this makes that official here.
|
23
|
-
|
23
|
+
update_attributes(params)
|
24
24
|
|
25
25
|
# Now remove any parameters that look like object attributes.
|
26
26
|
params = params.reject { |k, _| respond_to?(k) }
|
@@ -33,7 +33,7 @@ module Stripe
|
|
33
33
|
values.delete(:id)
|
34
34
|
|
35
35
|
response, opts = request(:post, req_url, values)
|
36
|
-
|
36
|
+
initialize_from(response, opts)
|
37
37
|
end
|
38
38
|
self
|
39
39
|
end
|
data/lib/stripe/api_resource.rb
CHANGED
data/lib/stripe/charge.rb
CHANGED
@@ -6,23 +6,23 @@ module Stripe
|
|
6
6
|
|
7
7
|
def refund(params={}, opts={})
|
8
8
|
response, opts = request(:post, refund_url, params, opts)
|
9
|
-
|
9
|
+
initialize_from(response, opts)
|
10
10
|
end
|
11
11
|
|
12
12
|
def capture(params={}, opts={})
|
13
13
|
response, opts = request(:post, capture_url, params, opts)
|
14
|
-
|
14
|
+
initialize_from(response, opts)
|
15
15
|
end
|
16
16
|
|
17
17
|
def update_dispute(params={}, opts={})
|
18
18
|
response, opts = request(:post, dispute_url, params, opts)
|
19
|
-
|
19
|
+
initialize_from({ :dispute => response }, opts, true)
|
20
20
|
dispute
|
21
21
|
end
|
22
22
|
|
23
23
|
def close_dispute(params={}, opts={})
|
24
24
|
response, opts = request(:post, close_dispute_url, params, opts)
|
25
|
-
|
25
|
+
initialize_from(response, opts)
|
26
26
|
end
|
27
27
|
|
28
28
|
def mark_as_fraudulent
|
@@ -30,7 +30,7 @@ module Stripe
|
|
30
30
|
:fraud_details => { :user_report => 'fraudulent' }
|
31
31
|
}
|
32
32
|
response, opts = request(:post, url, params)
|
33
|
-
|
33
|
+
initialize_from(response, opts)
|
34
34
|
end
|
35
35
|
|
36
36
|
def mark_as_safe
|
@@ -38,7 +38,7 @@ module Stripe
|
|
38
38
|
:fraud_details => { :user_report => 'safe' }
|
39
39
|
}
|
40
40
|
response, opts = request(:post, url, params)
|
41
|
-
|
41
|
+
initialize_from(response, opts)
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
data/lib/stripe/customer.rb
CHANGED
@@ -37,25 +37,25 @@ module Stripe
|
|
37
37
|
|
38
38
|
def cancel_subscription(params={}, opts={})
|
39
39
|
response, opts = request(:delete, subscription_url, params, opts)
|
40
|
-
|
40
|
+
initialize_from({ :subscription => response }, opts, true)
|
41
41
|
subscription
|
42
42
|
end
|
43
43
|
|
44
44
|
def update_subscription(params={}, opts={})
|
45
45
|
response, opts = request(:post, subscription_url, params, opts)
|
46
|
-
|
46
|
+
initialize_from({ :subscription => response }, opts, true)
|
47
47
|
subscription
|
48
48
|
end
|
49
49
|
|
50
50
|
def create_subscription(params={}, opts={})
|
51
51
|
response, opts = request(:post, subscriptions_url, params, opts)
|
52
|
-
|
52
|
+
initialize_from({ :subscription => response }, opts, true)
|
53
53
|
subscription
|
54
54
|
end
|
55
55
|
|
56
56
|
def delete_discount
|
57
57
|
_, opts = request(:delete, discount_url)
|
58
|
-
|
58
|
+
initialize_from({ :discount => nil }, opts, true)
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
data/lib/stripe/dispute.rb
CHANGED
data/lib/stripe/invoice.rb
CHANGED
data/lib/stripe/order.rb
CHANGED
data/lib/stripe/stripe_object.rb
CHANGED
@@ -22,7 +22,9 @@ module Stripe
|
|
22
22
|
|
23
23
|
def self.construct_from(values, opts={})
|
24
24
|
values = Stripe::Util.symbolize_names(values)
|
25
|
-
|
25
|
+
|
26
|
+
# work around protected #initialize_from for now
|
27
|
+
self.new(values[:id]).send(:initialize_from, values, opts)
|
26
28
|
end
|
27
29
|
|
28
30
|
# Determines the equality of two Stripe objects. Stripe objects are
|
@@ -32,6 +34,13 @@ module Stripe
|
|
32
34
|
@values == other.instance_variable_get(:@values)
|
33
35
|
end
|
34
36
|
|
37
|
+
# Indicates whether or not the resource has been deleted on the server.
|
38
|
+
# Note that some, but not all, resources can indicate whether they have
|
39
|
+
# been deleted.
|
40
|
+
def deleted?
|
41
|
+
@values.fetch(:deleted, false)
|
42
|
+
end
|
43
|
+
|
35
44
|
def to_s(*args)
|
36
45
|
JSON.pretty_generate(@values)
|
37
46
|
end
|
@@ -41,40 +50,36 @@ module Stripe
|
|
41
50
|
"#<#{self.class}:0x#{self.object_id.to_s(16)}#{id_string}> JSON: " + JSON.pretty_generate(@values)
|
42
51
|
end
|
43
52
|
|
53
|
+
# Re-initializes the object based on a hash of values (usually one that's
|
54
|
+
# come back from an API call). Adds or removes value accessors as necessary
|
55
|
+
# and updates the state of internal data.
|
56
|
+
#
|
57
|
+
# Please don't use this method. If you're trying to do mass assignment, try
|
58
|
+
# #initialize_from instead.
|
44
59
|
def refresh_from(values, opts, partial=false)
|
45
|
-
|
46
|
-
@original_values = Marshal.load(Marshal.dump(values)) # deep copy
|
47
|
-
|
48
|
-
removed = partial ? Set.new : Set.new(@values.keys - values.keys)
|
49
|
-
added = Set.new(values.keys - @values.keys)
|
50
|
-
|
51
|
-
# Wipe old state before setting new. This is useful for e.g. updating a
|
52
|
-
# customer, where there is no persistent card parameter. Mark those values
|
53
|
-
# which don't persist as transient
|
54
|
-
|
55
|
-
instance_eval do
|
56
|
-
remove_accessors(removed)
|
57
|
-
add_accessors(added, values)
|
58
|
-
end
|
59
|
-
|
60
|
-
removed.each do |k|
|
61
|
-
@values.delete(k)
|
62
|
-
@transient_values.add(k)
|
63
|
-
@unsaved_values.delete(k)
|
64
|
-
end
|
65
|
-
|
66
|
-
update_attributes_with_options(values, :opts => opts)
|
67
|
-
values.each do |k, _|
|
68
|
-
@transient_values.delete(k)
|
69
|
-
@unsaved_values.delete(k)
|
70
|
-
end
|
71
|
-
|
72
|
-
return self
|
60
|
+
initialize_from(values, opts, partial)
|
73
61
|
end
|
62
|
+
extend Gem::Deprecate
|
63
|
+
deprecate :refresh_from, "#update_attributes", 2016, 01
|
74
64
|
|
75
65
|
# Mass assigns attributes on the model.
|
76
|
-
|
77
|
-
|
66
|
+
#
|
67
|
+
# This is a version of +update_attributes+ that takes some extra options
|
68
|
+
# for internal use.
|
69
|
+
#
|
70
|
+
# ==== Attributes
|
71
|
+
#
|
72
|
+
# * +values+ - Hash of values to use to update the current attributes of
|
73
|
+
# the object.
|
74
|
+
#
|
75
|
+
# ==== Options
|
76
|
+
#
|
77
|
+
# * +:opts+ Options for StripeObject like an API key.
|
78
|
+
def update_attributes(values, opts = {})
|
79
|
+
values.each do |k, v|
|
80
|
+
@values[k] = Util.convert_to_stripe_object(v, opts)
|
81
|
+
@unsaved_values.add(k)
|
82
|
+
end
|
78
83
|
end
|
79
84
|
|
80
85
|
def [](k)
|
@@ -294,6 +299,49 @@ module Stripe
|
|
294
299
|
@values && @values.has_key?(symbol) || super
|
295
300
|
end
|
296
301
|
|
302
|
+
# Re-initializes the object based on a hash of values (usually one that's
|
303
|
+
# come back from an API call). Adds or removes value accessors as necessary
|
304
|
+
# and updates the state of internal data.
|
305
|
+
#
|
306
|
+
# Protected on purpose! Please do not expose.
|
307
|
+
#
|
308
|
+
# ==== Options
|
309
|
+
#
|
310
|
+
# * +:values:+ Hash used to update accessors and values.
|
311
|
+
# * +:opts:+ Options for StripeObject like an API key.
|
312
|
+
# * +:partial:+ Indicates that the re-initialization should not attempt to
|
313
|
+
# remove accessors.
|
314
|
+
def initialize_from(values, opts, partial=false)
|
315
|
+
@opts = Util.normalize_opts(opts)
|
316
|
+
@original_values = Marshal.load(Marshal.dump(values)) # deep copy
|
317
|
+
|
318
|
+
removed = partial ? Set.new : Set.new(@values.keys - values.keys)
|
319
|
+
added = Set.new(values.keys - @values.keys)
|
320
|
+
|
321
|
+
# Wipe old state before setting new. This is useful for e.g. updating a
|
322
|
+
# customer, where there is no persistent card parameter. Mark those values
|
323
|
+
# which don't persist as transient
|
324
|
+
|
325
|
+
instance_eval do
|
326
|
+
remove_accessors(removed)
|
327
|
+
add_accessors(added, values)
|
328
|
+
end
|
329
|
+
|
330
|
+
removed.each do |k|
|
331
|
+
@values.delete(k)
|
332
|
+
@transient_values.add(k)
|
333
|
+
@unsaved_values.delete(k)
|
334
|
+
end
|
335
|
+
|
336
|
+
update_attributes(values, :opts => opts)
|
337
|
+
values.each do |k, _|
|
338
|
+
@transient_values.delete(k)
|
339
|
+
@unsaved_values.delete(k)
|
340
|
+
end
|
341
|
+
|
342
|
+
self
|
343
|
+
end
|
344
|
+
|
297
345
|
# Mass assigns attributes on the model.
|
298
346
|
#
|
299
347
|
# This is a version of +update_attributes+ that takes some extra options
|
data/lib/stripe/subscription.rb
CHANGED
data/lib/stripe/transfer.rb
CHANGED
data/lib/stripe/util.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "cgi"
|
2
|
+
|
1
3
|
module Stripe
|
2
4
|
module Util
|
3
5
|
def self.objects_to_ids(h)
|
@@ -92,14 +94,30 @@ module Stripe
|
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
97
|
+
# Encodes a hash of parameters in a way that's suitable for use as query
|
98
|
+
# parameters in a URI or as form parameters in a request body. This mainly
|
99
|
+
# involves escaping special characters from parameter keys and values (e.g.
|
100
|
+
# `&`).
|
101
|
+
def self.encode_parameters(params)
|
102
|
+
Util.flatten_params(params).
|
103
|
+
map { |k,v| "#{url_encode(k)}=#{url_encode(v)}" }.join('&')
|
104
|
+
end
|
105
|
+
|
106
|
+
# Encodes a string in a way that makes it suitable for use in a set of
|
107
|
+
# query parameters in a URI or in a set of form parameters in a request
|
108
|
+
# body.
|
95
109
|
def self.url_encode(key)
|
96
|
-
|
110
|
+
CGI.escape(key.to_s).
|
111
|
+
# Don't use strict form encoding by changing the square bracket control
|
112
|
+
# characters back to their literals. This is fine by the server, and
|
113
|
+
# makes these parameter strings easier to read.
|
114
|
+
gsub('%5B', '[').gsub('%5D', ']')
|
97
115
|
end
|
98
116
|
|
99
117
|
def self.flatten_params(params, parent_key=nil)
|
100
118
|
result = []
|
101
119
|
params.each do |key, value|
|
102
|
-
calculated_key = parent_key ? "#{parent_key}[#{
|
120
|
+
calculated_key = parent_key ? "#{parent_key}[#{key}]" : "#{key}"
|
103
121
|
if value.is_a?(Hash)
|
104
122
|
result += flatten_params(value, calculated_key)
|
105
123
|
elsif value.is_a?(Array)
|
@@ -108,7 +126,12 @@ module Stripe
|
|
108
126
|
result << [calculated_key, value]
|
109
127
|
end
|
110
128
|
end
|
111
|
-
|
129
|
+
|
130
|
+
# The #sort_by call here is mostly so that we can get some stability in
|
131
|
+
# our 1.8.7 test suite where Hash key order is not preserved.
|
132
|
+
#
|
133
|
+
# https://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/
|
134
|
+
result.sort_by { |(k, _)| k }
|
112
135
|
end
|
113
136
|
|
114
137
|
def self.flatten_params_array(value, calculated_key)
|
data/lib/stripe/version.rb
CHANGED
data/test/stripe/account_test.rb
CHANGED
@@ -68,7 +68,7 @@ module Stripe
|
|
68
68
|
|
69
69
|
@mock.expects(:post).
|
70
70
|
once.
|
71
|
-
with('https://api.stripe.com/v1/accounts/acct_foo', nil, 'legal_entity[
|
71
|
+
with('https://api.stripe.com/v1/accounts/acct_foo', nil, 'legal_entity[address][line1]=2+Three+Four&legal_entity[first_name]=Bob').
|
72
72
|
returns(make_response(resp))
|
73
73
|
|
74
74
|
a = Stripe::Account.retrieve('acct_foo')
|
@@ -230,7 +230,7 @@ module Stripe
|
|
230
230
|
|
231
231
|
should "urlencode values in GET params" do
|
232
232
|
response = make_response(make_charge_array)
|
233
|
-
@mock.expects(:get).with("#{Stripe.api_base}/v1/charges?customer=test
|
233
|
+
@mock.expects(:get).with("#{Stripe.api_base}/v1/charges?customer=test+customer", nil, nil).returns(response)
|
234
234
|
charges = Stripe::Charge.list(:customer => 'test customer').data
|
235
235
|
assert charges.kind_of? Array
|
236
236
|
end
|
@@ -60,7 +60,7 @@ module Stripe
|
|
60
60
|
|
61
61
|
if is_greater_than_ruby_1_9?
|
62
62
|
check_metadata({:metadata => {:initial => 'true'}},
|
63
|
-
'metadata[
|
63
|
+
'metadata[initial]=&metadata[uuid]=6735',
|
64
64
|
update_actions)
|
65
65
|
end
|
66
66
|
end
|
@@ -93,7 +93,7 @@ module Stripe
|
|
93
93
|
obj.metadata['uuid'] = '6735'
|
94
94
|
end
|
95
95
|
params = {:metadata => {'type' => 'summer', 'uuid' => '6735'}}
|
96
|
-
curl_args = Stripe.
|
96
|
+
curl_args = Stripe::Util.encode_parameters(params)
|
97
97
|
check_metadata({:metadata => {'type' => 'christmas'}},
|
98
98
|
curl_args,
|
99
99
|
update_actions)
|
@@ -11,6 +11,17 @@ module Stripe
|
|
11
11
|
refute obj1 == obj3
|
12
12
|
end
|
13
13
|
|
14
|
+
should "implement #deleted?" do
|
15
|
+
obj = Stripe::StripeObject.construct_from({})
|
16
|
+
refute obj.deleted?
|
17
|
+
|
18
|
+
obj = Stripe::StripeObject.construct_from({ :deleted => false })
|
19
|
+
refute obj.deleted?
|
20
|
+
|
21
|
+
obj = Stripe::StripeObject.construct_from({ :deleted => true })
|
22
|
+
assert obj.deleted?
|
23
|
+
end
|
24
|
+
|
14
25
|
should "implement #respond_to" do
|
15
26
|
obj = Stripe::StripeObject.construct_from({ :id => 1, :foo => 'bar' })
|
16
27
|
assert obj.respond_to?(:id)
|
@@ -53,10 +64,25 @@ module Stripe
|
|
53
64
|
obj.update_attributes(:name => 'STRIPE')
|
54
65
|
assert_equal "STRIPE", obj.name
|
55
66
|
|
56
|
-
|
57
|
-
|
67
|
+
# unfortunately, we even assign unknown properties to duplicate the
|
68
|
+
# behavior that we currently have via magic accessors with
|
69
|
+
# method_missing
|
70
|
+
obj.update_attributes(:unknown => 'foo')
|
71
|
+
assert_equal "foo", obj.unknown
|
72
|
+
end
|
73
|
+
|
74
|
+
should "warn that #refresh_from is deprecated" do
|
75
|
+
old_stderr = $stderr
|
76
|
+
$stderr = StringIO.new
|
77
|
+
begin
|
78
|
+
obj = Stripe::StripeObject.construct_from({})
|
79
|
+
obj.refresh_from({}, {})
|
80
|
+
message = "NOTE: Stripe::StripeObject#refresh_from is " +
|
81
|
+
"deprecated; use #update_attributes instead"
|
82
|
+
assert_match Regexp.new(message), $stderr.string
|
83
|
+
ensure
|
84
|
+
$stderr = old_stderr
|
58
85
|
end
|
59
|
-
assert_equal "foo is not an attribute that can be assigned on this object", e.message
|
60
86
|
end
|
61
87
|
end
|
62
88
|
end
|
data/test/stripe/util_test.rb
CHANGED
@@ -2,7 +2,48 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class UtilTest < Test::Unit::TestCase
|
5
|
-
should "
|
5
|
+
should "#encode_parameters should prepare parameters for an HTTP request" do
|
6
|
+
params = {
|
7
|
+
:a => 3,
|
8
|
+
:b => "+foo?",
|
9
|
+
:c => "bar&baz",
|
10
|
+
:d => { :a => "a", :b => "b" },
|
11
|
+
:e => [0, 1],
|
12
|
+
}
|
13
|
+
assert_equal(
|
14
|
+
"a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[]=0&e[]=1",
|
15
|
+
Stripe::Util.encode_parameters(params)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
should "#url_encode should prepare strings for HTTP" do
|
20
|
+
assert_equal "foo", Stripe::Util.url_encode("foo")
|
21
|
+
assert_equal "foo", Stripe::Util.url_encode(:foo)
|
22
|
+
assert_equal "foo%2B", Stripe::Util.url_encode("foo+")
|
23
|
+
assert_equal "foo%26", Stripe::Util.url_encode("foo&")
|
24
|
+
assert_equal "foo[bar]", Stripe::Util.url_encode("foo[bar]")
|
25
|
+
end
|
26
|
+
|
27
|
+
should "#flatten_params should encode parameters according to Rails convention" do
|
28
|
+
params = {
|
29
|
+
:a => 3,
|
30
|
+
:b => "foo?",
|
31
|
+
:c => "bar&baz",
|
32
|
+
:d => { :a => "a", :b => "b" },
|
33
|
+
:e => [0, 1],
|
34
|
+
}
|
35
|
+
assert_equal([
|
36
|
+
["a", 3],
|
37
|
+
["b", "foo?"],
|
38
|
+
["c", "bar&baz"],
|
39
|
+
["d[a]", "a"],
|
40
|
+
["d[b]", "b"],
|
41
|
+
["e[]", 0],
|
42
|
+
["e[]", 1],
|
43
|
+
], Stripe::Util.flatten_params(params))
|
44
|
+
end
|
45
|
+
|
46
|
+
should "#symbolize_names should convert names to symbols" do
|
6
47
|
start = {
|
7
48
|
'foo' => 'bar',
|
8
49
|
'array' => [{ 'foo' => 'bar' }],
|
@@ -26,7 +67,7 @@ module Stripe
|
|
26
67
|
assert_equal(finish, symbolized)
|
27
68
|
end
|
28
69
|
|
29
|
-
should "normalize_opts should reject nil keys" do
|
70
|
+
should "#normalize_opts should reject nil keys" do
|
30
71
|
assert_raise { Stripe::Util.normalize_opts(nil) }
|
31
72
|
assert_raise { Stripe::Util.normalize_opts(:api_key => nil) }
|
32
73
|
end
|
data/test/stripe_test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
class StripeTest < Test::Unit::TestCase
|
4
|
+
should "warn that #refresh_from is deprecated" do
|
5
|
+
old_stderr = $stderr
|
6
|
+
$stderr = StringIO.new
|
7
|
+
begin
|
8
|
+
Stripe.uri_encode({})
|
9
|
+
message = "NOTE: Stripe.uri_encode is deprecated; use " +
|
10
|
+
"Stripe::Util#encode_parameters instead"
|
11
|
+
assert_match Regexp.new(message), $stderr.string
|
12
|
+
ensure
|
13
|
+
$stderr = old_stderr
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Boucher
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- test/stripe/subscription_test.rb
|
194
194
|
- test/stripe/transfer_test.rb
|
195
195
|
- test/stripe/util_test.rb
|
196
|
+
- test/stripe_test.rb
|
196
197
|
- test/test_data.rb
|
197
198
|
- test/test_helper.rb
|
198
199
|
homepage: https://stripe.com/api
|
@@ -247,6 +248,7 @@ test_files:
|
|
247
248
|
- test/stripe/subscription_test.rb
|
248
249
|
- test/stripe/transfer_test.rb
|
249
250
|
- test/stripe/util_test.rb
|
251
|
+
- test/stripe_test.rb
|
250
252
|
- test/test_data.rb
|
251
253
|
- test/test_helper.rb
|
252
254
|
has_rdoc:
|