Add support for deleting the discount associated with the customer

This commit is contained in:
John Wood 2012-01-13 06:40:24 -06:00
parent e05c49350b
commit 5921076da0
3 changed files with 24 additions and 0 deletions

View File

@ -369,8 +369,17 @@ module Stripe
subscription
end
def delete_discount(params={})
Stripe.request(:delete, discount_url, @api_key, params)
refresh_from({ :discount => nil }, api_key, true)
end
private
def discount_url
url + '/discount'
end
def subscription_url
url + '/subscription'
end

View File

@ -167,3 +167,10 @@ def test_api_error
}
}
end
def test_delete_discount_response
{
:deleted => true,
:id => "di_test_coupon"
}
end

View File

@ -313,6 +313,14 @@ class TestStripeRuby < Test::Unit::TestCase
@mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/subscription", {}, nil).returns(test_response(test_subscription('silver')))
s = c.cancel_subscription
end
should "be able to delete a customer's discount" do
@mock.expects(:get).once.returns(test_response(test_customer))
c = Stripe::Customer.retrieve("test_customer")
@mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/discount", {}, nil).returns(test_response(test_delete_discount_response))
s = c.delete_discount
end
end
context "card tests" do