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.



514
515
516
# File 'lib/google4r/checkout/shared.rb', line 514

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).



512
513
514
# File 'lib/google4r/checkout/shared.rb', line 512

def maximum_charge
  @maximum_charge
end

#subscriptionObject

Returns the value of attribute subscription.



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

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.



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

def times
  @times
end

Class Method Details

.create_from_element(subscription, element) ⇒ Object



528
529
530
531
532
533
534
535
536
537
538
# File 'lib/google4r/checkout/shared.rb', line 528

def self.create_from_element(subscription, element)
  result = SubscriptionPayment.new(subscription)
  result.subscription = subscription
  result.times = element.attributes['times'].to_i rescue nil
  
  maximum_charge = (BigDecimal.new(element.elements['maximum-charge'].text) * 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