mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-09-22 00:00:31 -04:00
Support deleting subscription discounts
This commit is contained in:
parent
06cfcc6131
commit
c4d5774170
@ -10,5 +10,16 @@ module Stripe
|
||||
def self.retrieve(id, api_key=nil)
|
||||
raise NotImplementedError.new("Subscriptions cannot be retrieved without a customer ID. Retrieve a subscription using customer.subscriptions.retrieve('subscription_id')")
|
||||
end
|
||||
|
||||
def delete_discount
|
||||
Stripe.request(:delete, discount_url, @api_key)
|
||||
refresh_from({ :discount => nil }, api_key, true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def discount_url
|
||||
url + '/discount'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -54,5 +54,19 @@ module Stripe
|
||||
subscription = customer.subscriptions.create(:plan => 'silver')
|
||||
assert_equal subscription.id, 'test_new_subscription'
|
||||
end
|
||||
|
||||
should "be able to delete a subscriptions's discount" do
|
||||
@mock.expects(:get).once.returns(test_response(test_customer))
|
||||
@mock.expects(:post).once.returns(test_response(test_subscription(:id => 'test_new_subscription')))
|
||||
|
||||
|
||||
customer = Stripe::Customer.retrieve("test_customer")
|
||||
subscription = customer.subscriptions.create(:plan => 'silver')
|
||||
|
||||
url = "#{Stripe.api_base}/v1/customers/c_test_customer/subscriptions/test_new_subscription/discount"
|
||||
@mock.expects(:delete).once.with(url, nil, nil).returns(test_response(test_delete_discount_response))
|
||||
subscription.delete_discount
|
||||
assert_equal nil, subscription.discount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user