stripe 1.31.0 → 1.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +5 -0
- data/.travis.yml +2 -12
- data/Gemfile +29 -4
- data/History.txt +168 -0
- data/README.md +134 -0
- data/Rakefile +10 -0
- data/VERSION +1 -1
- data/bin/stripe-console +12 -5
- data/lib/data/ca-certificates.crt +3868 -5114
- data/lib/stripe/account.rb +41 -21
- data/lib/stripe/alipay_account.rb +20 -0
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +1 -1
- data/lib/stripe/api_operations/list.rb +1 -2
- data/lib/stripe/api_operations/save.rb +87 -0
- data/lib/stripe/api_resource.rb +37 -4
- data/lib/stripe/apple_pay_domain.rb +12 -0
- data/lib/stripe/application_fee.rb +8 -8
- data/lib/stripe/application_fee_refund.rb +7 -3
- data/lib/stripe/balance_transaction.rb +1 -1
- data/lib/stripe/bank_account.rb +9 -5
- data/lib/stripe/bitcoin_receiver.rb +6 -6
- data/lib/stripe/bitcoin_transaction.rb +1 -1
- data/lib/stripe/card.rb +9 -5
- data/lib/stripe/charge.rb +30 -12
- data/lib/stripe/country_spec.rb +9 -0
- data/lib/stripe/coupon.rb +1 -1
- data/lib/stripe/customer.rb +6 -4
- data/lib/stripe/dispute.rb +2 -2
- data/lib/stripe/errors.rb +82 -0
- data/lib/stripe/file_upload.rb +1 -1
- data/lib/stripe/invoice.rb +3 -3
- data/lib/stripe/invoice_item.rb +1 -1
- data/lib/stripe/list_object.rb +7 -6
- data/lib/stripe/order.rb +10 -2
- data/lib/stripe/order_return.rb +9 -0
- data/lib/stripe/plan.rb +1 -1
- data/lib/stripe/product.rb +2 -10
- data/lib/stripe/recipient.rb +1 -1
- data/lib/stripe/refund.rb +1 -1
- data/lib/stripe/reversal.rb +7 -3
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/sku.rb +2 -2
- data/lib/stripe/source.rb +11 -0
- data/lib/stripe/stripe_object.rb +167 -91
- data/lib/stripe/subscription.rb +15 -9
- data/lib/stripe/subscription_item.rb +12 -0
- data/lib/stripe/three_d_secure.rb +9 -0
- data/lib/stripe/transfer.rb +3 -4
- data/lib/stripe/util.rb +100 -28
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +283 -140
- data/stripe.gemspec +5 -18
- data/test/stripe/account_test.rb +55 -9
- data/test/stripe/alipay_account_test.rb +11 -0
- data/test/stripe/api_operations_test.rb +31 -0
- data/test/stripe/api_resource_test.rb +204 -10
- data/test/stripe/apple_pay_domain_test.rb +34 -0
- data/test/stripe/application_fee_test.rb +8 -5
- data/test/stripe/bitcoin_receiver_test.rb +2 -2
- data/test/stripe/charge_refund_test.rb +12 -0
- data/test/stripe/charge_test.rb +32 -4
- data/test/stripe/country_spec_test.rb +43 -0
- data/test/stripe/coupon_test.rb +9 -1
- data/test/stripe/customer_card_test.rb +2 -2
- data/test/stripe/customer_test.rb +24 -1
- data/test/stripe/dispute_test.rb +8 -0
- data/test/stripe/errors_test.rb +18 -0
- data/test/stripe/invoice_item_test.rb +19 -0
- data/test/stripe/invoice_test.rb +27 -1
- data/test/stripe/list_object_test.rb +36 -15
- data/test/stripe/order_return_test.rb +25 -0
- data/test/stripe/order_test.rb +21 -1
- data/test/stripe/plan_test.rb +31 -0
- data/test/stripe/product_test.rb +17 -7
- data/test/stripe/recipient_card_test.rb +2 -2
- data/test/stripe/recipient_test.rb +21 -0
- data/test/stripe/refund_test.rb +10 -1
- data/test/stripe/sku_test.rb +15 -6
- data/test/stripe/source_test.rb +83 -0
- data/test/stripe/stripe_object_test.rb +180 -11
- data/test/stripe/subscription_item_test.rb +76 -0
- data/test/stripe/subscription_test.rb +161 -37
- data/test/stripe/three_d_secure_test.rb +22 -0
- data/test/stripe/transfer_test.rb +8 -0
- data/test/stripe/util_test.rb +48 -16
- data/test/stripe_test.rb +58 -0
- data/test/test_data.rb +337 -27
- data/test/test_helper.rb +7 -3
- metadata +47 -133
- data/README.rdoc +0 -68
- data/gemfiles/default-with-activesupport.gemfile +0 -10
- data/gemfiles/json.gemfile +0 -12
- data/gemfiles/yajl.gemfile +0 -12
- data/lib/stripe/api_operations/update.rb +0 -58
- data/lib/stripe/errors/api_connection_error.rb +0 -4
- data/lib/stripe/errors/api_error.rb +0 -4
- data/lib/stripe/errors/authentication_error.rb +0 -4
- data/lib/stripe/errors/card_error.rb +0 -12
- data/lib/stripe/errors/invalid_request_error.rb +0 -11
- data/lib/stripe/errors/rate_limit_error.rb +0 -4
- data/lib/stripe/errors/stripe_error.rb +0 -26
data/test/stripe/util_test.rb
CHANGED
@@ -3,23 +3,51 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
3
3
|
module Stripe
|
4
4
|
class UtilTest < Test::Unit::TestCase
|
5
5
|
should "#encode_parameters should prepare parameters for an HTTP request" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
params = {
|
7
|
+
:a => 3,
|
8
|
+
:b => "+foo?",
|
9
|
+
:c => "bar&baz",
|
10
|
+
:d => { :a => "a", :b => "b" },
|
11
|
+
:e => [0, 1],
|
12
|
+
:f => "",
|
13
13
|
|
14
14
|
# note the empty hash won't even show up in the request
|
15
|
-
|
16
|
-
|
15
|
+
:g => [],
|
16
|
+
}
|
17
17
|
assert_equal(
|
18
|
-
"a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[]=0&e[]=1",
|
18
|
+
"a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[]=0&e[]=1&f=",
|
19
19
|
Stripe::Util.encode_parameters(params)
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
|
+
should "#encode_params should throw an error on an array of maps that cannot be encoded" do
|
24
|
+
params = {
|
25
|
+
:a => [
|
26
|
+
{ :a => 1, :b => 2 },
|
27
|
+
{ :c => 3, :a => 4 },
|
28
|
+
]
|
29
|
+
}
|
30
|
+
e = assert_raises(ArgumentError) do
|
31
|
+
Stripe::Util.encode_parameters(params)
|
32
|
+
end
|
33
|
+
expected = "All maps nested in an array should start with the same key " +
|
34
|
+
"(expected starting key 'a', got 'c')"
|
35
|
+
assert_equal expected, e.message
|
36
|
+
|
37
|
+
# Make sure the check is recursive by taking our original params and
|
38
|
+
# nesting it into yet another map and array. Should throw exactly the
|
39
|
+
# same error because it's still the in inner array of maps that's wrong.
|
40
|
+
params = {
|
41
|
+
:x => [
|
42
|
+
params
|
43
|
+
]
|
44
|
+
}
|
45
|
+
e = assert_raises(ArgumentError) do
|
46
|
+
Stripe::Util.encode_parameters(params)
|
47
|
+
end
|
48
|
+
assert_equal expected, e.message
|
49
|
+
end
|
50
|
+
|
23
51
|
should "#url_encode should prepare strings for HTTP" do
|
24
52
|
assert_equal "foo", Stripe::Util.url_encode("foo")
|
25
53
|
assert_equal "foo", Stripe::Util.url_encode(:foo)
|
@@ -36,8 +64,8 @@ module Stripe
|
|
36
64
|
[:d, { :a => "a", :b => "b" }],
|
37
65
|
[:e, [0, 1]],
|
38
66
|
[:f, [
|
39
|
-
{ :
|
40
|
-
{ :
|
67
|
+
{ :foo => "1", :ghi => "2" },
|
68
|
+
{ :foo => "3", :bar => "4" },
|
41
69
|
]],
|
42
70
|
]
|
43
71
|
assert_equal([
|
@@ -52,10 +80,10 @@ module Stripe
|
|
52
80
|
# *The key here is the order*. In order to be properly interpreted as
|
53
81
|
# an array of hashes on the server, everything from a single hash must
|
54
82
|
# come in at once. A duplicate key in an array triggers a new element.
|
55
|
-
["f[][
|
56
|
-
["f[][
|
57
|
-
["f[][
|
58
|
-
["f[][
|
83
|
+
["f[][foo]", "1"],
|
84
|
+
["f[][ghi]", "2"],
|
85
|
+
["f[][foo]", "3"],
|
86
|
+
["f[][bar]", "4"],
|
59
87
|
], Stripe::Util.flatten_params(params))
|
60
88
|
end
|
61
89
|
|
@@ -113,5 +141,9 @@ module Stripe
|
|
113
141
|
obj = Util.convert_to_stripe_object([1, 2, 3], {})
|
114
142
|
assert_equal [1, 2, 3], obj
|
115
143
|
end
|
144
|
+
|
145
|
+
should "#array_to_hash should convert an array into a hash with integer keys" do
|
146
|
+
assert_equal({"0" => 1, "1" => 2, "2" => 3}, Util.array_to_hash([1, 2, 3]))
|
147
|
+
end
|
116
148
|
end
|
117
149
|
end
|
data/test/stripe_test.rb
CHANGED
@@ -13,4 +13,62 @@ class StripeTest < Test::Unit::TestCase
|
|
13
13
|
$stderr = old_stderr
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
should "allow ca_bundle_path to be configured" do
|
18
|
+
begin
|
19
|
+
old = Stripe.ca_bundle_path
|
20
|
+
Stripe.ca_bundle_path = "path/to/ca/bundle"
|
21
|
+
assert_equal "path/to/ca/bundle", Stripe.ca_bundle_path
|
22
|
+
ensure
|
23
|
+
Stripe.ca_bundle_path = old
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
should "allow max_network_retries to be configured" do
|
28
|
+
begin
|
29
|
+
old = Stripe.max_network_retries
|
30
|
+
Stripe.max_network_retries = 99
|
31
|
+
assert_equal 99, Stripe.max_network_retries
|
32
|
+
ensure
|
33
|
+
Stripe.max_network_retries = old
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should "makes requests with the Stripe-Account header" do
|
38
|
+
response = make_account(
|
39
|
+
charges_enabled: false,
|
40
|
+
details_submitted: false,
|
41
|
+
email: "test+bindings@stripe.com"
|
42
|
+
)
|
43
|
+
Stripe.stripe_account = 'acct_1234'
|
44
|
+
|
45
|
+
Stripe.expects(:execute_request).with(
|
46
|
+
has_entry(:headers, has_entry('Stripe-Account', 'acct_1234')),
|
47
|
+
).returns(make_response(response))
|
48
|
+
|
49
|
+
Stripe.request(:post, '/v1/account', 'sk_live12334566')
|
50
|
+
end
|
51
|
+
|
52
|
+
context "#get_uname" do
|
53
|
+
should "run without failure" do
|
54
|
+
# Don't actually check the result because we try a variety of different
|
55
|
+
# strategies that will have different results depending on where this
|
56
|
+
# test and running. We're mostly making sure that no exception is thrown.
|
57
|
+
_ = Stripe.get_uname
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "#get_uname_from_system" do
|
62
|
+
should "run without failure" do
|
63
|
+
# as above, just verify that an exception is not thrown
|
64
|
+
_ = Stripe.get_uname_from_system
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "#get_uname_from_system_ver" do
|
69
|
+
should "run without failure" do
|
70
|
+
# as above, just verify that an exception is not thrown
|
71
|
+
_ = Stripe.get_uname_from_system_ver
|
72
|
+
end
|
73
|
+
end
|
16
74
|
end
|