Class: Paypal::Payment::Recurring

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

Defined Under Namespace

Classes: Activation, Billing, Summary

Constant Summary collapse

MANDATORY_PARAMETERS =
[:DESC, :PROFILESTARTDATE, :BILLINGPERIOD, :BILLINGFREQUENCY, :AMT, :CURRENCYCODE].freeze

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.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/paypal/payment/recurring.rb', line 9

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]
  @raw_parameters = attributes[:raw].presence || {}
  @parameters = build_parameters_hash

  # can not make this happen as profile object is used both in cretion, response verification and status checks, which vary in available parameters
  # makes sure key params have been passed one way or the other
  # missing_mandatory_parameters = MANDATORY_PARAMETERS.map{|param| @parameters[param].present? ? nil : param}.compact
  # raise ArgumentError.new("Missing mandatory parameters #{missing_mandatory_parameters.to_s}") if missing_mandatory_parameters.any?
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)


28
29
30
# File 'lib/paypal/payment/recurring.rb', line 28

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

#to_paramsObject



24
25
26
# File 'lib/paypal/payment/recurring.rb', line 24

def to_params
  return @parameters
end