Class: Paypal::Payment::Recurring::Billing

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#==, formatted_amount, #numeric_attribute?, to_numeric

Constructor Details

#initialize(attributes = {}) ⇒ Billing

Returns a new instance of Billing.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/paypal/payment/recurring/billing.rb', line 7

def initialize(attributes = {})
  @amount = if attributes[:amount].is_a?(Common::Amount)
    attributes[:amount]
  else
    Common::Amount.new(
      :total => attributes[:amount],
      :tax => attributes[:tax_amount],
      :shipping => attributes[:shipping_amount]
    )
  end
  super
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

Instance Method Details

#to_paramsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/paypal/payment/recurring/billing.rb', line 20

def to_params
  {
    :BILLINGPERIOD => self.period,
    :BILLINGFREQUENCY => self.frequency,
    :TOTALBILLINGCYCLES => self.total_cycles,
    :AMT => Util.formatted_amount(self.amount.total),
    :TRIALBILLINGPERIOD => self.trial_period,
    :TRIALBILLINGFREQUENCY => self.trial_frequency,
    :TRIALTOTALBILLINGCYCLES => self.trial_total_cycles,
    :TRIALAMT => Util.formatted_amount(self.trial_amount),
    :CURRENCYCODE => self.currency_code,
    :SHIPPINGAMT => Util.formatted_amount(self.amount.shipping),
    :TAXAMT => Util.formatted_amount(self.amount.tax)
  }
end