Class: Google4R::Checkout::ChargeAmountNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::ChargeAmountNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends
Instance Attribute Summary collapse
-
#latest_charge_amount ⇒ Object
The amount most recently charged for an order (Money).
-
#total_charge_amount ⇒ Object
The total amount charged for an order (Money).
Attributes inherited from Notification
#frontend, #google_order_number, #serial_number, #timestamp
Class Method Summary collapse
-
.create_from_element(element, frontend) ⇒ Object
Factory method that creates a new ChargeAmountNotification from an REXML::Element instance.
Methods inherited from Notification
Constructor Details
This class inherits a constructor from Google4R::Checkout::Notification
Instance Attribute Details
#latest_charge_amount ⇒ Object
The amount most recently charged for an order (Money)
294 295 296 |
# File 'lib/google4r/checkout/notifications.rb', line 294 def latest_charge_amount @latest_charge_amount end |
#total_charge_amount ⇒ Object
The total amount charged for an order (Money)
297 298 299 |
# File 'lib/google4r/checkout/notifications.rb', line 297 def total_charge_amount @total_charge_amount end |
Class Method Details
.create_from_element(element, frontend) ⇒ Object
Factory method that creates a new ChargeAmountNotification from an REXML::Element instance. Use this to create instances of ChargeAmountNotification.
Raises NoMethodError and RuntimeError exceptions if the given element misses required elements.
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/google4r/checkout/notifications.rb', line 304 def self.create_from_element(element, frontend) charge = ChargeAmountNotification.new(frontend) charge.serial_number = element.attributes['serial-number'] charge.google_order_number = element.elements['google-order-number'].text currency = element.elements['latest-charge-amount'].attributes['currency'] amount = (element.elements['latest-charge-amount'].text.to_f*100).to_i charge.latest_charge_amount = Money.new(amount, currency) currency = element.elements['total-charge-amount'].attributes['currency'] amount = (element.elements['total-charge-amount'].text.to_f*100).to_i charge.total_charge_amount = Money.new(amount, currency) charge. = Time.parse(element.elements['timestamp'].text) return charge end |