Class: Google4R::Checkout::ChargebackAmountNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::ChargebackAmountNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends a
Instance Attribute Summary collapse
-
#latest_chargeback_amount ⇒ Object
The amount most recently charged back for an order (Money).
-
#total_chargeback_amount ⇒ Object
The total amount charged back 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 ChargebackAmountNotification from an REXML::Element instance.
Methods inherited from Notification
Constructor Details
This class inherits a constructor from Google4R::Checkout::Notification
Instance Attribute Details
#latest_chargeback_amount ⇒ Object
The amount most recently charged back for an order (Money)
367 368 369 |
# File 'lib/google4r/checkout/notifications.rb', line 367 def latest_chargeback_amount @latest_chargeback_amount end |
#total_chargeback_amount ⇒ Object
The total amount charged back for an order (Money)
370 371 372 |
# File 'lib/google4r/checkout/notifications.rb', line 370 def total_chargeback_amount @total_chargeback_amount end |
Class Method Details
.create_from_element(element, frontend) ⇒ Object
Factory method that creates a new ChargebackAmountNotification from an REXML::Element instance. Use this to create instances of ChargebackAmountNotification.
Raises NoMethodError and RuntimeError exceptions if the given element misses required elements.
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/google4r/checkout/notifications.rb', line 377 def self.create_from_element(element, frontend) chargeback = ChargebackAmountNotification.new(frontend) chargeback.serial_number = element.attributes['serial-number'] chargeback.google_order_number = element.elements['google-order-number'].text currency = element.elements['latest-chargeback-amount'].attributes['currency'] amount = (element.elements['latest-chargeback-amount'].text.to_f*100).to_i chargeback.latest_chargeback_amount = Money.new(amount, currency) currency = element.elements['total-chargeback-amount'].attributes['currency'] amount = (element.elements['total-chargeback-amount'].text.to_f*100).to_i chargeback.total_chargeback_amount = Money.new(amount, currency) chargeback. = Time.parse(element.elements['timestamp'].text) return chargeback end |