mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-09 00:03:05 -04:00
Add support for deleting the discount associated with the customer
This commit is contained in:
parent
e05c49350b
commit
5921076da0
@ -369,8 +369,17 @@ module Stripe
|
|||||||
subscription
|
subscription
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_discount(params={})
|
||||||
|
Stripe.request(:delete, discount_url, @api_key, params)
|
||||||
|
refresh_from({ :discount => nil }, api_key, true)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def discount_url
|
||||||
|
url + '/discount'
|
||||||
|
end
|
||||||
|
|
||||||
def subscription_url
|
def subscription_url
|
||||||
url + '/subscription'
|
url + '/subscription'
|
||||||
end
|
end
|
||||||
|
@ -167,3 +167,10 @@ def test_api_error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_delete_discount_response
|
||||||
|
{
|
||||||
|
:deleted => true,
|
||||||
|
:id => "di_test_coupon"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
@ -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')))
|
@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
|
s = c.cancel_subscription
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "card tests" do
|
context "card tests" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user