Class: Stripe::Customer

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

Instance Attribute Summary

Attributes inherited from StripeObject

#api_key

Instance Method Summary (collapse)

Methods included from APIOperations::List

included

Methods included from APIOperations::Update

#save

Methods included from APIOperations::Delete

#delete

Methods included from APIOperations::Create

included

Methods inherited from APIResource

class_name, #refresh, retrieve, url, #url

Methods inherited from StripeObject

#[], #[]=, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #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

Instance Method Details

- (Object) add_invoice_item(params)



8
9
10
# File 'lib/stripe/customer.rb', line 8

def add_invoice_item(params)
  InvoiceItem.create(params.merge(:customer => id), @api_key)
end

- (Object) cancel_subscription(params = {})



24
25
26
27
28
# File 'lib/stripe/customer.rb', line 24

def cancel_subscription(params={})
  response, api_key = Stripe.request(:delete, subscription_url, @api_key, params)
  refresh_from({ :subscription => response }, api_key, true)
  subscription
end

- (Object) charges



20
21
22
# File 'lib/stripe/customer.rb', line 20

def charges
  Charge.all({ :customer => id }, @api_key)
end

- (Object) delete_discount



36
37
38
39
# File 'lib/stripe/customer.rb', line 36

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

- (Object) invoice_items



16
17
18
# File 'lib/stripe/customer.rb', line 16

def invoice_items
  InvoiceItem.all({ :customer => id }, @api_key)
end

- (Object) invoices



12
13
14
# File 'lib/stripe/customer.rb', line 12

def invoices
  Invoice.all({ :customer => id }, @api_key)
end

- (Object) update_subscription(params)



30
31
32
33
34
# File 'lib/stripe/customer.rb', line 30

def update_subscription(params)
  response, api_key = Stripe.request(:post, subscription_url, @api_key, params)
  refresh_from({ :subscription => response }, api_key, true)
  subscription
end