Class: Google4R::Checkout::ChargeAmountNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::ChargeAmountNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends <charge-amount-notification> messages to the web service when the to confirm that the charge was successfully executed.
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)
296 297 298 |
# File 'lib/google4r/checkout/notifications.rb', line 296 def latest_charge_amount @latest_charge_amount end |
#total_charge_amount ⇒ Object
The total amount charged for an order (Money)
299 300 301 |
# File 'lib/google4r/checkout/notifications.rb', line 299 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.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/google4r/checkout/notifications.rb', line 306 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 |