Class: Paypal::Payment::Recurring::Billing
- Defined in:
- lib/paypal/payment/recurring/billing.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#trial ⇒ Object
Returns the value of attribute trial.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Billing
constructor
A new instance of Billing.
- #to_params ⇒ Object
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 19 |
# 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 @trial = Recurring::Billing.new(attributes[:trial]) if attributes[:trial].present? super end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/paypal/payment/recurring/billing.rb', line 5 def amount @amount end |
#trial ⇒ Object
Returns the value of attribute trial.
5 6 7 |
# File 'lib/paypal/payment/recurring/billing.rb', line 5 def trial @trial end |
Instance Method Details
#to_params ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/paypal/payment/recurring/billing.rb', line 21 def to_params trial_params = (trial.try(:to_params) || {}).inject({}) do |trial_params, (key, value)| trial_params.merge( :"TRIAL#{key}" => value ) end trial_params.merge( :BILLINGPERIOD => self.period, :BILLINGFREQUENCY => self.frequency, :TOTALBILLINGCYCLES => self.total_cycles, :AMT => Util.formatted_amount(self.amount.total), :CURRENCYCODE => self.currency_code, :SHIPPINGAMT => Util.formatted_amount(self.amount.shipping), :TAXAMT => Util.formatted_amount(self.amount.tax) ) end |