stripe 1.7.3 → 1.7.4

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.
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.8.7
4
+ - 1.9.2
4
5
  - 1.9.3
5
6
  gemfile:
6
7
  - gemfiles/default-with-activesupport.gemfile
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stripe (1.7.3)
4
+ stripe (1.7.4)
5
5
  multi_json (~> 1.1)
6
6
  rest-client (~> 1.4)
7
7
 
@@ -1,3 +1,8 @@
1
+ === 1.7.4 2012-10-08
2
+
3
+ * Fix bug introduced in 1.7.3 calling API methods that take no
4
+ arguments, like Stripe::Invoice#pay (github issue #42)
5
+
1
6
  === 1.7.3 2012-09-14
2
7
 
3
8
  * Make sure that both keys and values of GET params are
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.3
1
+ 1.7.4
@@ -77,7 +77,7 @@ module Stripe
77
77
  @@verify_ssl_certs
78
78
  end
79
79
 
80
- def self.request(method, url, api_key, params=nil, headers={})
80
+ def self.request(method, url, api_key, params={}, headers={})
81
81
  api_key ||= @@api_key
82
82
  raise AuthenticationError.new('No API key provided. (HINT: set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.)') unless api_key
83
83
 
@@ -115,7 +115,7 @@ module Stripe
115
115
  case method.to_s.downcase.to_sym
116
116
  when :get, :head, :delete
117
117
  # Make params into GET parameters
118
- if params && params.count
118
+ if params && params.count > 0
119
119
  query_string = Util.flatten_params(params).collect{|key, value| "#{key}=#{Util.url_encode(value)}"}.join('&')
120
120
  url += "?#{query_string}"
121
121
  end
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.7.3'
2
+ VERSION = '1.7.4'
3
3
  end
@@ -129,6 +129,58 @@ def test_subscription(plan_id="gold")
129
129
  }
130
130
  end
131
131
 
132
+ def test_invoice
133
+ {
134
+ :id => 'in_test_invoice',
135
+ :object => 'invoice',
136
+ :livemode => false,
137
+ :amount_due => 1000,
138
+ :attempt_count => 0,
139
+ :attempted => false,
140
+ :closed => false,
141
+ :currency => 'usd',
142
+ :customer => 'c_test_customer',
143
+ :date => 1349738950,
144
+ :lines => {
145
+ "invoiceitems" => [
146
+ {
147
+ :id => 'ii_test_invoice_item',
148
+ :object => '',
149
+ :livemode => false,
150
+ :amount => 1000,
151
+ :currency => 'usd',
152
+ :customer => 'c_test_customer',
153
+ :date => 1349738950,
154
+ :description => "A Test Invoice Item",
155
+ :invoice => 'in_test_invoice'
156
+ },
157
+ ],
158
+ },
159
+ :paid => false,
160
+ :period_end => 1349738950,
161
+ :period_start => 1349738950,
162
+ :starting_balance => 0,
163
+ :subtotal => 1000,
164
+ :total => 1000,
165
+ :charge => nil,
166
+ :discount => nil,
167
+ :ending_balance => nil,
168
+ :next_payemnt_attempt => 1349825350,
169
+ }
170
+ end
171
+
172
+ def test_paid_invoice
173
+ test_invoice.merge({
174
+ :attempt_count => 1,
175
+ :attempted => true,
176
+ :closed => true,
177
+ :paid => true,
178
+ :charge => 'ch_test_charge',
179
+ :ending_balance => 0,
180
+ :next_payment_attempt => nil,
181
+ })
182
+ end
183
+
132
184
  def test_invalid_api_key_error
133
185
  {
134
186
  "error" => {
@@ -410,7 +410,7 @@ class TestStripeRuby < Test::Unit::TestCase
410
410
  @mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/subscription?at_period_end=true", nil, nil).returns(test_response(test_subscription('silver')))
411
411
  s = c.cancel_subscription({:at_period_end => 'true'})
412
412
 
413
- @mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/subscription?", nil, nil).returns(test_response(test_subscription('silver')))
413
+ @mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/subscription", nil, nil).returns(test_response(test_subscription('silver')))
414
414
  s = c.cancel_subscription
415
415
  end
416
416
 
@@ -434,6 +434,24 @@ class TestStripeRuby < Test::Unit::TestCase
434
434
  assert_equal "co_test_coupon", c.id
435
435
  end
436
436
  end
437
+
438
+ context "invoice tests" do
439
+ should "retrieve should retrieve invoices" do
440
+ @mock.expects(:get).once.returns(test_response(test_invoice))
441
+ i = Stripe::Invoice.retrieve('in_test_invoice')
442
+ assert_equal 'in_test_invoice', i.id
443
+ end
444
+
445
+ should "pay should pay an invoice" do
446
+ @mock.expects(:get).once.returns(test_response(test_invoice))
447
+ i = Stripe::Invoice.retrieve('in_test_invoice')
448
+
449
+ @mock.expects(:post).once.with('https://api.stripe.com/v1/invoices/in_test_invoice/pay', nil, '').returns(test_response(test_paid_invoice))
450
+ i.pay
451
+ assert_equal i.next_payment_attempt, nil
452
+ end
453
+ end
454
+
437
455
  context "error checking" do
438
456
 
439
457
  should "404s should raise an InvalidRequestError" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
- - 3
10
- version: 1.7.3
9
+ - 4
10
+ version: 1.7.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ross Boucher
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-09-15 00:00:00 Z
19
+ date: 2012-10-09 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false