Class: Stripe::Subscription

Inherits:
APIResource show all
Includes:
APIOperations::Delete, APIOperations::Update
Defined in:
lib/stripe/subscription.rb

Instance Attribute Summary

Attributes inherited from StripeObject

#api_key

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Delete

#delete

Methods included from APIOperations::Update

#save, #serialize_metadata, #serialize_params

Methods inherited from APIResource

class_name, #refresh, url

Methods inherited from StripeObject

#[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #to_hash, #to_json, #to_s, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Class Method Details

.retrieve(id, api_key = nil) ⇒ Object

Raises:

  • (NotImplementedError)


10
11
12
# File 'lib/stripe/subscription.rb', line 10

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

Instance Method Details

#delete_discountObject



14
15
16
17
# File 'lib/stripe/subscription.rb', line 14

def delete_discount
  Stripe.request(:delete, discount_url, @api_key)
  refresh_from({ :discount => nil }, api_key, true)
end

#urlObject



6
7
8
# File 'lib/stripe/subscription.rb', line 6

def url
  "#{Customer.url}/#{CGI.escape(customer)}/subscriptions/#{CGI.escape(id)}"
end