stripe 1.23.0 → 1.24.0
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 +4 -4
- data/History.txt +6 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/stripe.rb +7 -3
- data/lib/stripe/account.rb +1 -0
- data/lib/stripe/dispute.rb +16 -0
- data/lib/stripe/list_object.rb +2 -1
- data/lib/stripe/stripe_object.rb +1 -9
- data/lib/stripe/util.rb +14 -2
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/api_resource_test.rb +36 -0
- data/test/stripe/charge_test.rb +19 -0
- data/test/stripe/dispute_test.rb +45 -0
- data/test/test_data.rb +25 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ecbd18ba821963c6f74fe3f77824f17abc2fe69
|
4
|
+
data.tar.gz: 88b6c051bb7a499cd1b0fe9ca017c56ee6ad3290
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bcd08d62d22be5862e078ec20c574c2dde8045ebc4a9897853dbf695909e5a62ac9ea8cd417d9385aeba2078ff42ab9221f55e10aa9412f7d43a9fc5ca099d3
|
7
|
+
data.tar.gz: 09b0cb29cba10c861f4453cb648df2dacea2e7d1424ad1a1b141083b6ff5cb3f5cfbd105665aa22c98777e7df1e8d095733e4188c9eb16f911cf1d475453137a
|
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Stripe Ruby bindings {<img src="https://travis-ci.org/stripe/stripe-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/stripe/stripe-ruby]
|
1
|
+
= Stripe Ruby bindings {<img src="https://travis-ci.org/stripe/stripe-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/stripe/stripe-ruby]
|
2
2
|
|
3
3
|
== Documentation
|
4
4
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.24.0
|
data/lib/stripe.rb
CHANGED
@@ -48,6 +48,7 @@ require 'stripe/reversal'
|
|
48
48
|
require 'stripe/application_fee_refund'
|
49
49
|
require 'stripe/bitcoin_receiver'
|
50
50
|
require 'stripe/bitcoin_transaction'
|
51
|
+
require 'stripe/dispute'
|
51
52
|
|
52
53
|
# Errors
|
53
54
|
require 'stripe/errors/stripe_error'
|
@@ -66,9 +67,12 @@ module Stripe
|
|
66
67
|
@ssl_bundle_path = DEFAULT_CA_BUNDLE_PATH
|
67
68
|
@verify_ssl_certs = true
|
68
69
|
|
70
|
+
@open_timeout = 30
|
71
|
+
@read_timeout = 80
|
69
72
|
|
70
73
|
class << self
|
71
|
-
attr_accessor :api_key, :api_base, :verify_ssl_certs, :api_version, :connect_base, :uploads_base
|
74
|
+
attr_accessor :api_key, :api_base, :verify_ssl_certs, :api_version, :connect_base, :uploads_base,
|
75
|
+
:open_timeout, :read_timeout
|
72
76
|
end
|
73
77
|
|
74
78
|
def self.api_url(url='', api_base_url=nil)
|
@@ -123,8 +127,8 @@ module Stripe
|
|
123
127
|
end
|
124
128
|
|
125
129
|
request_opts.update(:headers => request_headers(api_key).update(headers),
|
126
|
-
:method => method, :open_timeout =>
|
127
|
-
:payload => payload, :url => url, :timeout =>
|
130
|
+
:method => method, :open_timeout => open_timeout,
|
131
|
+
:payload => payload, :url => url, :timeout => read_timeout)
|
128
132
|
|
129
133
|
begin
|
130
134
|
response = execute_request(request_opts)
|
data/lib/stripe/account.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Stripe
|
2
|
+
class Dispute < APIResource
|
3
|
+
include Stripe::APIOperations::List
|
4
|
+
include Stripe::APIOperations::Create
|
5
|
+
include Stripe::APIOperations::Update
|
6
|
+
|
7
|
+
def close(params={}, opts={})
|
8
|
+
response, opts = request(:post, close_url, params, opts)
|
9
|
+
refresh_from(response, opts)
|
10
|
+
end
|
11
|
+
|
12
|
+
def close_url
|
13
|
+
url + '/close'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/stripe/list_object.rb
CHANGED
@@ -16,7 +16,8 @@ module Stripe
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def retrieve(id, opts={})
|
19
|
-
|
19
|
+
id, retrieve_params = Util.normalize_id(id)
|
20
|
+
response, opts = request(:get,"#{url}/#{CGI.escape(id)}", retrieve_params, opts)
|
20
21
|
Util.convert_to_stripe_object(response, opts)
|
21
22
|
end
|
22
23
|
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -10,15 +10,7 @@ module Stripe
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize(id=nil, opts={})
|
13
|
-
|
14
|
-
if id.kind_of?(Hash)
|
15
|
-
@retrieve_params = id.dup
|
16
|
-
@retrieve_params.delete(:id)
|
17
|
-
id = id[:id]
|
18
|
-
else
|
19
|
-
@retrieve_params = {}
|
20
|
-
end
|
21
|
-
|
13
|
+
id, @retrieve_params = Util.normalize_id(id)
|
22
14
|
@opts = opts
|
23
15
|
@values = {}
|
24
16
|
# This really belongs in APIResource, but not putting it there allows us
|
data/lib/stripe/util.rb
CHANGED
@@ -39,10 +39,12 @@ module Stripe
|
|
39
39
|
'refund' => Refund,
|
40
40
|
'subscription' => Subscription,
|
41
41
|
'file_upload' => FileUpload,
|
42
|
+
'token' => Token,
|
42
43
|
'transfer' => Transfer,
|
43
44
|
'transfer_reversal' => Reversal,
|
44
45
|
'bitcoin_receiver' => BitcoinReceiver,
|
45
|
-
'bitcoin_transaction' => BitcoinTransaction
|
46
|
+
'bitcoin_transaction' => BitcoinTransaction,
|
47
|
+
'dispute' => Dispute
|
46
48
|
}
|
47
49
|
end
|
48
50
|
|
@@ -110,7 +112,7 @@ module Stripe
|
|
110
112
|
result = []
|
111
113
|
value.each do |elem|
|
112
114
|
if elem.is_a?(Hash)
|
113
|
-
result += flatten_params(elem, calculated_key)
|
115
|
+
result += flatten_params(elem, "#{calculated_key}[]")
|
114
116
|
elsif elem.is_a?(Array)
|
115
117
|
result += flatten_params_array(elem, calculated_key)
|
116
118
|
else
|
@@ -120,6 +122,16 @@ module Stripe
|
|
120
122
|
result
|
121
123
|
end
|
122
124
|
|
125
|
+
def self.normalize_id(id)
|
126
|
+
if id.kind_of?(Hash) # overloaded id
|
127
|
+
params_hash = id.dup
|
128
|
+
id = params_hash.delete(:id)
|
129
|
+
else
|
130
|
+
params_hash = {}
|
131
|
+
end
|
132
|
+
[id, params_hash]
|
133
|
+
end
|
134
|
+
|
123
135
|
# The secondary opts argument can either be a string or hash
|
124
136
|
# Turn this value into an api_key and a set of headers
|
125
137
|
def self.normalize_opts(opts)
|
data/lib/stripe/version.rb
CHANGED
@@ -93,6 +93,19 @@ module Stripe
|
|
93
93
|
ch.refresh
|
94
94
|
end
|
95
95
|
|
96
|
+
should "send expand when fetching through ListObject" do
|
97
|
+
@mock.expects(:get).once.
|
98
|
+
with("#{Stripe.api_base}/v1/customers/c_test_customer", nil, nil).
|
99
|
+
returns(make_response(make_customer))
|
100
|
+
|
101
|
+
@mock.expects(:get).once.
|
102
|
+
with("#{Stripe.api_base}/v1/customers/c_test_customer/sources/cc_test_card?expand[]=customer", nil, nil).
|
103
|
+
returns(make_response(make_card))
|
104
|
+
|
105
|
+
customer = Stripe::Customer.retrieve('c_test_customer')
|
106
|
+
customer.sources.retrieve({:id => 'cc_test_card', :expand => [:customer]})
|
107
|
+
end
|
108
|
+
|
96
109
|
should "send stripe account as header when set" do
|
97
110
|
stripe_account = "acct_0000"
|
98
111
|
Stripe.expects(:execute_request).with do |opts|
|
@@ -112,6 +125,29 @@ module Stripe
|
|
112
125
|
'sk_test_local')
|
113
126
|
end
|
114
127
|
|
128
|
+
should "have default open and read timeouts" do
|
129
|
+
assert_equal Stripe.open_timeout, 30
|
130
|
+
assert_equal Stripe.read_timeout, 80
|
131
|
+
end
|
132
|
+
|
133
|
+
should "allow configurable open and read timeouts" do
|
134
|
+
original_timeouts = Stripe.open_timeout, Stripe.read_timeout
|
135
|
+
|
136
|
+
begin
|
137
|
+
Stripe.open_timeout = 999
|
138
|
+
Stripe.read_timeout = 998
|
139
|
+
|
140
|
+
Stripe.expects(:execute_request).with do |opts|
|
141
|
+
opts[:open_timeout] == 999 && opts[:timeout] == 998
|
142
|
+
end.returns(make_response(make_charge))
|
143
|
+
|
144
|
+
Stripe::Charge.create({:card => {:number => '4242424242424242'}},
|
145
|
+
'sk_test_local')
|
146
|
+
ensure
|
147
|
+
Stripe.open_timeout, Stripe.read_timeout = original_timeouts
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
115
151
|
context "when specifying per-object credentials" do
|
116
152
|
context "with no global API key set" do
|
117
153
|
should "use the per-object credential when creating" do
|
data/test/stripe/charge_test.rb
CHANGED
@@ -95,5 +95,24 @@ module Stripe
|
|
95
95
|
})
|
96
96
|
assert c.paid
|
97
97
|
end
|
98
|
+
|
99
|
+
should "properly handle an array or dictionaries" do
|
100
|
+
@mock.expects(:post).with do |url, api_key, params|
|
101
|
+
url == "#{Stripe.api_base}/v1/charges" && api_key.nil? && CGI.parse(params) == {
|
102
|
+
'currency' => ['usd'], 'amount' => ['100'],
|
103
|
+
'source' => ['btcrcv_test_receiver'],
|
104
|
+
'level3[][red]' => ['firstred', 'another'],
|
105
|
+
'level3[][one]' => ['fish'],
|
106
|
+
}
|
107
|
+
end.once.returns(make_response(make_charge))
|
108
|
+
|
109
|
+
c = Stripe::Charge.create({
|
110
|
+
:amount => 100,
|
111
|
+
:source => 'btcrcv_test_receiver',
|
112
|
+
:currency => "usd",
|
113
|
+
:level3 => [{:red => 'firstred'}, {:one => 'fish', :red => 'another'}]
|
114
|
+
})
|
115
|
+
assert c.paid
|
116
|
+
end
|
98
117
|
end
|
99
118
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class DisputeTest < Test::Unit::TestCase
|
5
|
+
should "disputes should be retrievable" do
|
6
|
+
@mock.expects(:get).once.returns(make_response(make_dispute))
|
7
|
+
d = Stripe::Dispute.retrieve('dp_test_dispute')
|
8
|
+
assert d.kind_of?(Stripe::Dispute)
|
9
|
+
end
|
10
|
+
|
11
|
+
should "disputes should be listable" do
|
12
|
+
@mock.expects(:get).once.returns(make_response(make_dispute_array))
|
13
|
+
d = Stripe::Dispute.all
|
14
|
+
assert d.data.kind_of? Array
|
15
|
+
d.each do |dispute|
|
16
|
+
assert dispute.kind_of?(Stripe::Dispute)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
should "disputes should be closeable" do
|
21
|
+
@mock.expects(:get).never
|
22
|
+
@mock.expects(:post).with(
|
23
|
+
"#{Stripe.api_base}/v1/disputes/test_dispute/close",
|
24
|
+
nil,
|
25
|
+
''
|
26
|
+
).once.returns(make_response({:id => 'dp_test_dispute', :status => 'lost'}))
|
27
|
+
d = Stripe::Dispute.new('test_dispute')
|
28
|
+
d.close
|
29
|
+
end
|
30
|
+
|
31
|
+
should "disputes should be updateable" do
|
32
|
+
@mock.expects(:get).once.returns(make_response(make_dispute))
|
33
|
+
@mock.expects(:post).with(
|
34
|
+
"#{Stripe.api_base}/v1/disputes/dp_test_dispute",
|
35
|
+
nil,
|
36
|
+
'evidence[customer_name]=customer'
|
37
|
+
).once.returns(make_response(make_dispute))
|
38
|
+
|
39
|
+
d = Stripe::Dispute.new('test_dispute')
|
40
|
+
d.refresh
|
41
|
+
d.evidence['customer_name'] = 'customer'
|
42
|
+
d.save
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/test_data.rb
CHANGED
@@ -156,6 +156,31 @@ module Stripe
|
|
156
156
|
}
|
157
157
|
end
|
158
158
|
|
159
|
+
|
160
|
+
def make_dispute(params={})
|
161
|
+
id = params[:id] || 'dp_test_dispute'
|
162
|
+
{
|
163
|
+
:id => id,
|
164
|
+
:charge => "ch_test_charge",
|
165
|
+
:amount => 500,
|
166
|
+
:created => 1304114758,
|
167
|
+
:status => 'needs_response',
|
168
|
+
:livemode => false,
|
169
|
+
:currency => 'usd',
|
170
|
+
:object => 'dispute',
|
171
|
+
:reason => 'fraudulent',
|
172
|
+
:evidence => {},
|
173
|
+
}.merge(params)
|
174
|
+
end
|
175
|
+
|
176
|
+
def make_dispute_array
|
177
|
+
{
|
178
|
+
:data => [make_dispute, make_dispute, make_dispute],
|
179
|
+
:object => 'list',
|
180
|
+
:url => '/v1/disputes'
|
181
|
+
}
|
182
|
+
end
|
183
|
+
|
159
184
|
def make_recipient_card_array(recipient_id)
|
160
185
|
{
|
161
186
|
:data => [make_card, make_card, make_card],
|
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.24.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-
|
12
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/stripe/charge.rb
|
139
139
|
- lib/stripe/coupon.rb
|
140
140
|
- lib/stripe/customer.rb
|
141
|
+
- lib/stripe/dispute.rb
|
141
142
|
- lib/stripe/errors/api_connection_error.rb
|
142
143
|
- lib/stripe/errors/api_error.rb
|
143
144
|
- lib/stripe/errors/authentication_error.rb
|
@@ -171,6 +172,7 @@ files:
|
|
171
172
|
- test/stripe/coupon_test.rb
|
172
173
|
- test/stripe/customer_card_test.rb
|
173
174
|
- test/stripe/customer_test.rb
|
175
|
+
- test/stripe/dispute_test.rb
|
174
176
|
- test/stripe/file_upload_test.rb
|
175
177
|
- test/stripe/invoice_test.rb
|
176
178
|
- test/stripe/list_object_test.rb
|
@@ -219,6 +221,7 @@ test_files:
|
|
219
221
|
- test/stripe/coupon_test.rb
|
220
222
|
- test/stripe/customer_card_test.rb
|
221
223
|
- test/stripe/customer_test.rb
|
224
|
+
- test/stripe/dispute_test.rb
|
222
225
|
- test/stripe/file_upload_test.rb
|
223
226
|
- test/stripe/invoice_test.rb
|
224
227
|
- test/stripe/list_object_test.rb
|