mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-09-22 00:00:31 -04:00
Revert "Clearing out subscription code/tests from Customer."
This reverts commit d6ebab33109ff2501ba9709d2ac1dd666be0ab67. We'll support the legacy single-subscription API style indefinitely, and also we generaly try to make it so that people can use modern bindings with out-of-date API versions.
This commit is contained in:
parent
97f8df2934
commit
8231fba217
@ -25,6 +25,18 @@ module Stripe
|
||||
Charge.all({ :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)
|
||||
# subscription
|
||||
#end
|
||||
|
||||
#def update_subscription(params)
|
||||
# response, api_key = Stripe.request(:post, subscription_url, @api_key, params)
|
||||
# refresh_from({ :subscription => response }, api_key, true)
|
||||
# subscription
|
||||
#end
|
||||
|
||||
def delete_discount
|
||||
Stripe.request(:delete, discount_url, @api_key)
|
||||
refresh_from({ :discount => nil }, api_key, true)
|
||||
@ -35,5 +47,9 @@ module Stripe
|
||||
def discount_url
|
||||
url + '/discount'
|
||||
end
|
||||
|
||||
def subscription_url
|
||||
url + '/subscription'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -32,6 +32,32 @@ module Stripe
|
||||
assert_equal "c_test_customer", c.id
|
||||
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")
|
||||
|
||||
@mock.expects(:post).once.with do |url, api_key, params|
|
||||
url == "#{Stripe.api_base}/v1/customers/c_test_customer/subscription" && api_key.nil? && CGI.parse(params) == {'plan' => ['silver']}
|
||||
end.returns(test_response(test_subscription('silver')))
|
||||
s = c.update_subscription({:plan => 'silver'})
|
||||
|
||||
assert_equal 'subscription', s.object
|
||||
assert_equal 'silver', s.plan.identifier
|
||||
end
|
||||
|
||||
should "be able to cancel a customer's subscription" do
|
||||
@mock.expects(:get).once.returns(test_response(test_customer))
|
||||
c = Stripe::Customer.retrieve("test_customer")
|
||||
|
||||
# Not an accurate response, but whatever
|
||||
|
||||
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscription?at_period_end=true", nil, nil).returns(test_response(test_subscription('silver')))
|
||||
c.cancel_subscription({:at_period_end => 'true'})
|
||||
|
||||
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscription", nil, nil).returns(test_response(test_subscription('silver')))
|
||||
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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user