stripe 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.14.0 2014-06-17
2
+
3
+ * 1 major enhancement:
4
+ * Add metadata for refunds and disputes
5
+
1
6
  === 1.13.0 2014-05-28
2
7
 
3
8
  * 1 major enhancement:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.13.0
1
+ 1.14.0
data/lib/stripe.rb CHANGED
@@ -38,6 +38,7 @@ require 'stripe/recipient'
38
38
  require 'stripe/card'
39
39
  require 'stripe/subscription'
40
40
  require 'stripe/application_fee'
41
+ require 'stripe/refund'
41
42
 
42
43
  # Errors
43
44
  require 'stripe/errors/stripe_error'
@@ -87,7 +88,7 @@ module Stripe
87
88
  :ssl_ca_file => @ssl_bundle_path)
88
89
  end
89
90
 
90
- unless @CERTIFICATE_VERIFIED
91
+ if @verify_ssl_certs and !@CERTIFICATE_VERIFIED
91
92
  @CERTIFICATE_VERIFIED = CertificateBlacklist.check_ssl_cert(@api_base, @ssl_bundle_path)
92
93
  end
93
94
 
@@ -0,0 +1,13 @@
1
+ module Stripe
2
+ class Refund < APIResource
3
+ include Stripe::APIOperations::Update
4
+
5
+ def url
6
+ "#{Charge.url}/#{CGI.escape(charge)}/refunds/#{CGI.escape(id)}"
7
+ end
8
+
9
+ def self.retrieve(id, api_key=nil)
10
+ raise NotImplementedError.new("Refunds cannot be retrieved without a charge ID. Retrieve a refund using charge.refunds.retrieve('refund_id')")
11
+ end
12
+ end
13
+ end
data/lib/stripe/util.rb CHANGED
@@ -31,6 +31,7 @@ module Stripe
31
31
  'card' => Card,
32
32
  'subscription' => Subscription,
33
33
  'list' => ListObject,
34
+ 'refund' => Refund,
34
35
  'application_fee' => ApplicationFee
35
36
  }
36
37
  end
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.13.0'
2
+ VERSION = '1.14.0'
3
3
  end
@@ -111,4 +111,4 @@ module Stripe
111
111
  Gem::Version.new(version) >= Gem::Version.new('1.9')
112
112
  end
113
113
  end
114
- end
114
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Stripe
4
+ class RefundTest < Test::Unit::TestCase
5
+ should "refunds should be listable" do
6
+ @mock.expects(:get).once.returns(test_response(test_charge))
7
+
8
+ charge = Stripe::Charge.retrieve('test_charge')
9
+
10
+ assert charge.refunds.first.kind_of?(Stripe::Refund)
11
+ end
12
+
13
+ should "refunds should be refreshable" do
14
+ @mock.expects(:get).twice.returns(test_response(test_charge), test_response(test_refund(:id => 'refreshed_refund')))
15
+
16
+ charge = Stripe::Charge.retrieve('test_charge')
17
+ refund = charge.refunds.first
18
+ refund.refresh
19
+
20
+ assert_equal 'refreshed_refund', refund.id
21
+ end
22
+
23
+ should "refunds should be updateable" do
24
+ @mock.expects(:get).once.returns(test_response(test_charge))
25
+ @mock.expects(:post).once.returns(test_response(test_refund(:metadata => {'key' => 'value'})))
26
+
27
+ charge = Stripe::Charge.retrieve('test_charge')
28
+ refund = charge.refunds.first
29
+
30
+ assert_equal nil, refund.metadata['key']
31
+
32
+ refund.metadata['key'] = 'valu'
33
+ refund.save
34
+
35
+ assert_equal 'value', refund.metadata['key']
36
+ end
37
+
38
+ should "create should return a new refund" do
39
+ @mock.expects(:get).once.returns(test_response(test_charge))
40
+ @mock.expects(:post).once.returns(test_response(test_refund(:id => 'test_new_refund')))
41
+
42
+ charge = Stripe::Charge.retrieve('test_charge')
43
+ refund = charge.refunds.create(:amount => 20)
44
+ assert_equal 'test_new_refund', refund.id
45
+ end
46
+ end
47
+ end
data/test/test_helper.rb CHANGED
@@ -119,6 +119,7 @@ def test_customer_array
119
119
  end
120
120
 
121
121
  def test_charge(params={})
122
+ id = params[:id] || 'ch_test_charge'
122
123
  {
123
124
  :refunded => false,
124
125
  :paid => true,
@@ -132,12 +133,13 @@ def test_charge(params={})
132
133
  :id => "cc_test_card",
133
134
  :object => "card"
134
135
  },
135
- :id => "ch_test_charge",
136
+ :id => id,
136
137
  :reason => "execute_charge",
137
138
  :livemode => false,
138
139
  :currency => "usd",
139
140
  :object => "charge",
140
141
  :created => 1304114826,
142
+ :refunds => test_refund_array(id),
141
143
  :metadata => {}
142
144
  }.merge(params)
143
145
  end
@@ -204,6 +206,18 @@ def test_subscription(params = {})
204
206
  }.merge(params)
205
207
  end
206
208
 
209
+ def test_refund(params = {})
210
+ {
211
+ :object => 'refund',
212
+ :amount => 30,
213
+ :currency => "usd",
214
+ :created => 1308595038,
215
+ :id => "ref_test_refund",
216
+ :charge => "ch_test_charge",
217
+ :metadata => {}
218
+ }.merge(params)
219
+ end
220
+
207
221
  def test_subscription_array(customer_id)
208
222
  {
209
223
  :data => [test_subscription, test_subscription, test_subscription],
@@ -212,6 +226,15 @@ def test_subscription_array(customer_id)
212
226
  }
213
227
  end
214
228
 
229
+ def test_refund_array(charge_id)
230
+ {
231
+ :data => [test_refund, test_refund, test_refund],
232
+ :object => 'list',
233
+ :url => '/v1/charges/' + charge_id + '/refunds'
234
+ }
235
+ end
236
+
237
+
215
238
  def test_invoice
216
239
  {
217
240
  :id => 'in_test_invoice',
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.13.0
4
+ version: 1.14.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-05-28 00:00:00.000000000 Z
13
+ date: 2014-06-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -175,6 +175,7 @@ files:
175
175
  - lib/stripe/list_object.rb
176
176
  - lib/stripe/plan.rb
177
177
  - lib/stripe/recipient.rb
178
+ - lib/stripe/refund.rb
178
179
  - lib/stripe/singleton_api_resource.rb
179
180
  - lib/stripe/stripe_object.rb
180
181
  - lib/stripe/subscription.rb
@@ -195,6 +196,7 @@ files:
195
196
  - test/stripe/list_object_test.rb
196
197
  - test/stripe/metadata_test.rb
197
198
  - test/stripe/recipient_card_test.rb
199
+ - test/stripe/refund_test.rb
198
200
  - test/stripe/stripe_object_test.rb
199
201
  - test/stripe/subscription_test.rb
200
202
  - test/stripe/transfer_test.rb
@@ -238,6 +240,7 @@ test_files:
238
240
  - test/stripe/list_object_test.rb
239
241
  - test/stripe/metadata_test.rb
240
242
  - test/stripe/recipient_card_test.rb
243
+ - test/stripe/refund_test.rb
241
244
  - test/stripe/stripe_object_test.rb
242
245
  - test/stripe/subscription_test.rb
243
246
  - test/stripe/transfer_test.rb