Fix invoice paying/fetching upcoming

Fixes #209
This commit is contained in:
Brian Krausz 2015-02-18 12:24:07 -08:00
parent a85e2277d6
commit 9a82f7d1ba
2 changed files with 17 additions and 4 deletions

View File

@ -5,13 +5,12 @@ module Stripe
include Stripe::APIOperations::Create include Stripe::APIOperations::Create
def self.upcoming(params, opts={}) def self.upcoming(params, opts={})
opts = Util.normalize_opts(opts) response, opts = request(:get, upcoming_url, params, opts)
response, api_key = Stripe.request(:get, upcoming_url, opts, params)
Util.convert_to_stripe_object(response, opts) Util.convert_to_stripe_object(response, opts)
end end
def pay def pay(opts={})
response, opts = Stripe.request(:post, pay_url, @opts, {}) response, opts = request(:post, pay_url, {}, opts)
refresh_from(response, opts) refresh_from(response, opts)
end end

View File

@ -22,5 +22,19 @@ module Stripe
i.pay i.pay
assert_equal nil, i.next_payment_attempt assert_equal nil, i.next_payment_attempt
end end
should "pay with extra opts should pay an invoice" do
@mock.expects(:get).once.returns(test_response(test_invoice))
i = Stripe::Invoice.retrieve('in_test_invoice', {api_key: 'foobar'})
Stripe.expects(:execute_request).with do |opts|
opts[:url] == "#{Stripe.api_base}/v1/invoices/in_test_invoice/pay" &&
opts[:method] == :post &&
opts[:headers][:authorization] == 'Bearer foobar'
end.returns(test_response(test_paid_invoice))
i.pay
assert_equal nil, i.next_payment_attempt
end
end end
end end