Class: Paypal::Payment::Recurring

Inherits:
Base
  • Object
show all
Defined in:
lib/paypal/payment/recurring.rb

Defined Under Namespace

Classes: Activation, Billing, Summary

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#==, formatted_amount, to_numeric

Constructor Details

#initialize(attributes = {}) ⇒ Recurring

Returns a new instance of Recurring.



7
8
9
10
11
12
13
# File 'lib/paypal/payment/recurring.rb', line 7

def initialize(attributes = {})
  super
  @activation = Activation.new attributes[:activation] if attributes[:activation]
  @billing = Billing.new attributes[:billing] if attributes[:billing]
  @regular_billing = Billing.new attributes[:regular_billing] if attributes[:regular_billing]
  @summary = Summary.new attributes[:summary] if attributes[:summary]
end

Instance Attribute Details

#activationObject

Returns the value of attribute activation.



5
6
7
# File 'lib/paypal/payment/recurring.rb', line 5

def activation
  @activation
end

#billingObject

Returns the value of attribute billing.



5
6
7
# File 'lib/paypal/payment/recurring.rb', line 5

def billing
  @billing
end

#regular_billingObject

Returns the value of attribute regular_billing.



5
6
7
# File 'lib/paypal/payment/recurring.rb', line 5

def regular_billing
  @regular_billing
end

#summaryObject

Returns the value of attribute summary.



5
6
7
# File 'lib/paypal/payment/recurring.rb', line 5

def summary
  @summary
end

Instance Method Details

#numeric_attribute?(key) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/paypal/payment/recurring.rb', line 38

def numeric_attribute?(key)
  super || [:max_fails, :failed_count].include?(key)
end

#to_paramsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/paypal/payment/recurring.rb', line 15

def to_params
  params = [
    self.billing,
    self.activation
  ].compact.inject({}) do |params, attribute|
    params.merge! attribute.to_params
  end
  if self.start_date.is_a?(Time)
    self.start_date = self.start_date.to_s(:db)
  end
  params.merge!(
    :DESC  => self.description,
    :MAXFAILEDPAYMENTS => self.max_fails,
    :AUTOBILLOUTAMT => self.auto_bill,
    :PROFILESTARTDATE => self.start_date,
    :SUBSCRIBERNAME => self.name,
    :PROFILEREFERENCE => self.reference
  )
  params.delete_if do |k, v|
    v.blank?
  end
end