Class: Google4R::Checkout::Item::Subscription::SubscriptionPayment

Inherits:
Object
  • Object
show all
Defined in:
lib/google4r/checkout/shared.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subscription) ⇒ SubscriptionPayment

Returns a new instance of SubscriptionPayment.



507
508
509
# File 'lib/google4r/checkout/shared.rb', line 507

def initialize(subscription)
  @subscription = subscription
end

Instance Attribute Details

#maximum_chargeObject

The maximum amount that you will be allowed to charge the customer, including tax, for all recurrences (Money instance, required).



505
506
507
# File 'lib/google4r/checkout/shared.rb', line 505

def maximum_charge
  @maximum_charge
end

#subscriptionObject

Returns the value of attribute subscription.



493
494
495
# File 'lib/google4r/checkout/shared.rb', line 493

def subscription
  @subscription
end

#timesObject

Optional. The times attribute indicates how many times you will charge the customer for a defined subscription payment. A subscription may have multiple payment schedules, and the times attribute lets you indicate how many times each charge will be assessed. For example, you might charge the customer a reduced rate for the first three months of a subscription and then charge the standard rate each month thereafter.



501
502
503
# File 'lib/google4r/checkout/shared.rb', line 501

def times
  @times
end

Class Method Details

.create_from_element(subscription, element) ⇒ Object



521
522
523
524
525
526
527
528
529
530
531
# File 'lib/google4r/checkout/shared.rb', line 521

def self.create_from_element(subscription, element)
  result = SubscriptionPayment.new
  result.subscription = subscription
  result.times = element.attributes['times'].to_i rescue nil
  
  maximum_charge = (element.elements['maximum-charge'].text.to_f * 100).to_i
  maximum_charge_currency = element.elements['maximum-charge'].attributes['currency']
  result.maximum_charge = Money.new(maximum_charge, maximum_charge_currency)
  
  return result
end