Class: Braintree::Subscription

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/subscription.rb

Overview

Defined Under Namespace

Modules: Status, TrialDurationUnit

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

- (Subscription) initialize(gateway, attributes)

:nodoc:



69
70
71
72
73
74
75
76
77
78
# File 'lib/braintree/subscription.rb', line 69

def initialize(gateway, attributes) # :nodoc:
  @gateway = gateway
  set_instance_variables_from_hash(attributes)
  @balance = Util.to_big_decimal(balance)
  @price = Util.to_big_decimal(price)
  @descriptor = Descriptor.new(@descriptor)
  transactions.map! { |attrs| Transaction._new(gateway, attrs) }
  add_ons.map! { |attrs| AddOn._new(attrs) }
  discounts.map! { |attrs| Discount._new(attrs) }
end

Instance Attribute Details

- (Object) add_ons (readonly)

Returns the value of attribute add_ons



29
30
31
# File 'lib/braintree/subscription.rb', line 29

def add_ons
  @add_ons
end

- (Object) balance (readonly)

Returns the value of attribute balance



23
24
25
# File 'lib/braintree/subscription.rb', line 23

def balance
  @balance
end

- (Object) billing_day_of_month (readonly)

Returns the value of attribute billing_day_of_month



28
29
30
# File 'lib/braintree/subscription.rb', line 28

def billing_day_of_month
  @billing_day_of_month
end

- (Object) billing_period_end_date (readonly)

Returns the value of attribute billing_period_end_date



22
23
24
# File 'lib/braintree/subscription.rb', line 22

def billing_period_end_date
  @billing_period_end_date
end

- (Object) billing_period_start_date (readonly)

Returns the value of attribute billing_period_start_date



22
23
24
# File 'lib/braintree/subscription.rb', line 22

def billing_period_start_date
  @billing_period_start_date
end

- (Object) days_past_due (readonly)

Returns the value of attribute days_past_due



21
22
23
# File 'lib/braintree/subscription.rb', line 21

def days_past_due
  @days_past_due
end

- (Object) descriptor (readonly)

Returns the value of attribute descriptor



30
31
32
# File 'lib/braintree/subscription.rb', line 30

def descriptor
  @descriptor
end

- (Object) discounts (readonly)

Returns the value of attribute discounts



29
30
31
# File 'lib/braintree/subscription.rb', line 29

def discounts
  @discounts
end

- (Object) failure_count (readonly)

Returns the value of attribute failure_count



25
26
27
# File 'lib/braintree/subscription.rb', line 25

def failure_count
  @failure_count
end

- (Object) first_billing_date (readonly)

Returns the value of attribute first_billing_date



22
23
24
# File 'lib/braintree/subscription.rb', line 22

def first_billing_date
  @first_billing_date
end

- (Object) id (readonly)

Returns the value of attribute id



21
22
23
# File 'lib/braintree/subscription.rb', line 21

def id
  @id
end

- (Object) merchant_account_id (readonly)

Returns the value of attribute merchant_account_id



21
22
23
# File 'lib/braintree/subscription.rb', line 21

def 
  @merchant_account_id
end

- (Object) next_billing_date (readonly)

Returns the value of attribute next_billing_date



22
23
24
# File 'lib/braintree/subscription.rb', line 22

def next_billing_date
  @next_billing_date
end

- (Object) next_billing_period_amount (readonly)

Returns the value of attribute next_billing_period_amount



27
28
29
# File 'lib/braintree/subscription.rb', line 27

def next_billing_period_amount
  @next_billing_period_amount
end

- (Object) number_of_billing_cycles (readonly)

Returns the value of attribute number_of_billing_cycles



28
29
30
# File 'lib/braintree/subscription.rb', line 28

def number_of_billing_cycles
  @number_of_billing_cycles
end

Returns the value of attribute paid_through_date



23
24
25
# File 'lib/braintree/subscription.rb', line 23

def paid_through_date
  @paid_through_date
end

- (Object) payment_method_token (readonly)

Returns the value of attribute payment_method_token



21
22
23
# File 'lib/braintree/subscription.rb', line 21

def payment_method_token
  @payment_method_token
end

- (Object) plan_id (readonly)

Returns the value of attribute plan_id



21
22
23
# File 'lib/braintree/subscription.rb', line 21

def plan_id
  @plan_id
end

- (Object) price (readonly)

Returns the value of attribute price



21
22
23
# File 'lib/braintree/subscription.rb', line 21

def price
  @price
end

- (Object) status (readonly)

Returns the value of attribute status



21
22
23
# File 'lib/braintree/subscription.rb', line 21

def status
  @status
end

- (Object) transactions (readonly)

Returns the value of attribute transactions



26
27
28
# File 'lib/braintree/subscription.rb', line 26

def transactions
  @transactions
end

- (Object) trial_duration (readonly)

Returns the value of attribute trial_duration



24
25
26
# File 'lib/braintree/subscription.rb', line 24

def trial_duration
  @trial_duration
end

- (Object) trial_duration_unit (readonly)

Returns the value of attribute trial_duration_unit



24
25
26
# File 'lib/braintree/subscription.rb', line 24

def trial_duration_unit
  @trial_duration_unit
end

- (Object) trial_period (readonly)

Returns the value of attribute trial_period



24
25
26
# File 'lib/braintree/subscription.rb', line 24

def trial_period
  @trial_period
end

Class Method Details

+ (Object) _new(*args)

:nodoc:



97
98
99
# File 'lib/braintree/subscription.rb', line 97

def _new(*args) # :nodoc:
  self.new *args
end

+ (Object) cancel(subscription_id)



33
34
35
# File 'lib/braintree/subscription.rb', line 33

def self.cancel(subscription_id)
  Configuration.gateway.subscription.cancel(subscription_id)
end

+ (Object) create(attributes)



38
39
40
# File 'lib/braintree/subscription.rb', line 38

def self.create(attributes)
  Configuration.gateway.subscription.create(attributes)
end

+ (Object) create!(attributes)



42
43
44
# File 'lib/braintree/subscription.rb', line 42

def self.create!(attributes)
  return_object_or_raise(:subscription) { create(attributes) }
end

+ (Object) find(id)



47
48
49
# File 'lib/braintree/subscription.rb', line 47

def self.find(id)
  Configuration.gateway.subscription.find(id)
end

+ (Object) retry_charge(subscription_id, amount = nil)



51
52
53
# File 'lib/braintree/subscription.rb', line 51

def self.retry_charge(subscription_id, amount=nil)
  Configuration.gateway.transaction.retry_subscription_charge(subscription_id, amount)
end

+ (Object) search(&block)



56
57
58
# File 'lib/braintree/subscription.rb', line 56

def self.search(&block)
  Configuration.gateway.subscription.search(&block)
end

+ (Object) update(subscription_id, attributes)



61
62
63
# File 'lib/braintree/subscription.rb', line 61

def self.update(subscription_id, attributes)
  Configuration.gateway.subscription.update(subscription_id, attributes)
end

+ (Object) update!(subscription_id, attributes)



65
66
67
# File 'lib/braintree/subscription.rb', line 65

def self.update!(subscription_id, attributes)
  return_object_or_raise(:subscription) { update(subscription_id, attributes) }
end

Instance Method Details

- (Object) ==(other)

True if other has the same id.



90
91
92
93
# File 'lib/braintree/subscription.rb', line 90

def ==(other)
  return false unless other.is_a?(Subscription)
  id == other.id
end

- (Boolean) never_expires?

Returns:

  • (Boolean)


85
86
87
# File 'lib/braintree/subscription.rb', line 85

def never_expires?
  @never_expires
end

- (Object) next_bill_amount



80
81
82
83
# File 'lib/braintree/subscription.rb', line 80

def next_bill_amount
  warn "[DEPRECATED] Subscription.next_bill_amount is deprecated. Please use Subscription.next_billing_period_amount"
  @next_bill_amount
end