Merge pull request #97 from surfacedamage/customer-create-upcoming-invoice

Allow creation of new Invoice off Customer
This commit is contained in:
Andrew Thorp 2014-01-24 20:46:08 -08:00
commit ff7595c006
3 changed files with 17 additions and 1 deletions

View File

@ -25,6 +25,10 @@ module Stripe
Charge.all({ :customer => id }, @api_key)
end
def create_upcoming_invoice(params={})
Invoice.create(params.merge(:customer => id), @api_key)
end
def cancel_subscription(params={})
response, api_key = Stripe.request(:delete, subscription_url, @api_key, params)
refresh_from({ :subscription => response }, api_key, true)

View File

@ -32,6 +32,12 @@ module Stripe
assert_equal "c_test_customer", c.id
end
should "create_upcoming_invoice should create a new invoice" do
@mock.expects(:post).once.returns(test_response(test_invoice))
i = Stripe::Customer.new("test_customer").create_upcoming_invoice
assert_equal "c_test_customer", i.customer
end
should "be able to update a customer's subscription" do
@mock.expects(:get).once.returns(test_response(test_customer))
c = Stripe::Customer.retrieve("test_customer")

View File

@ -8,6 +8,12 @@ module Stripe
assert_equal 'in_test_invoice', i.id
end
should "create should create a new invoice" do
@mock.expects(:post).once.returns(test_response(test_invoice))
i = Stripe::Invoice.create
assert_equal "in_test_invoice", i.id
end
should "pay should pay an invoice" do
@mock.expects(:get).once.returns(test_response(test_invoice))
i = Stripe::Invoice.retrieve('in_test_invoice')
@ -17,4 +23,4 @@ module Stripe
assert_equal i.next_payment_attempt, nil
end
end
end
end