Class: Google4R::Checkout::RefundAmountNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::RefundAmountNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends a
Instance Attribute Summary collapse
-
#latest_refund_amount ⇒ Object
The amount most recently refunded for an order (Money).
-
#total_refund_amount ⇒ Object
The total amount refunded 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 RefundAmountNotification from an REXML::Element instance.
Methods inherited from Notification
Constructor Details
This class inherits a constructor from Google4R::Checkout::Notification
Instance Attribute Details
#latest_refund_amount ⇒ Object
The amount most recently refunded for an order (Money)
330 331 332 |
# File 'lib/google4r/checkout/notifications.rb', line 330 def latest_refund_amount @latest_refund_amount end |
#total_refund_amount ⇒ Object
The total amount refunded for an order (Money)
333 334 335 |
# File 'lib/google4r/checkout/notifications.rb', line 333 def total_refund_amount @total_refund_amount end |
Class Method Details
.create_from_element(element, frontend) ⇒ Object
Factory method that creates a new RefundAmountNotification from an REXML::Element instance. Use this to create instances of RefundAmountNotification.
Raises NoMethodError and RuntimeError exceptions if the given element misses required elements.
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/google4r/checkout/notifications.rb', line 340 def self.create_from_element(element, frontend) refund = RefundAmountNotification.new(frontend) refund.serial_number = element.attributes['serial-number'] refund.google_order_number = element.elements['google-order-number'].text currency = element.elements['latest-refund-amount'].attributes['currency'] amount = (element.elements['latest-refund-amount'].text.to_f*100).to_i refund.latest_refund_amount = Money.new(amount, currency) currency = element.elements['total-refund-amount'].attributes['currency'] amount = (element.elements['total-refund-amount'].text.to_f*100).to_i refund.total_refund_amount = Money.new(amount, currency) refund. = Time.parse(element.elements['timestamp'].text) return refund end |