Class: Google4R::Checkout::RefundAmountNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::RefundAmountNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends a <refund-amount-notification> after successfully executing a <refund-order> order processing command. See the Google Checkout documentation for more details: code.google.com/apis/checkout/developer/index.html#refund_amount_notification
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)
332 333 334 |
# File 'lib/google4r/checkout/notifications.rb', line 332 def latest_refund_amount @latest_refund_amount end |
#total_refund_amount ⇒ Object
The total amount refunded for an order (Money)
335 336 337 |
# File 'lib/google4r/checkout/notifications.rb', line 335 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.
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/google4r/checkout/notifications.rb', line 342 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 |