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_fee_refund_amount ⇒ Object
The amount of the fee refunded by Google (Money).
-
#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_fee_refund_amount ⇒ Object
The amount of the fee refunded by Google (Money)
353 354 355 |
# File 'lib/google4r/checkout/notifications.rb', line 353 def latest_fee_refund_amount @latest_fee_refund_amount end |
#latest_refund_amount ⇒ Object
The amount most recently refunded for an order (Money)
347 348 349 |
# File 'lib/google4r/checkout/notifications.rb', line 347 def latest_refund_amount @latest_refund_amount end |
#total_refund_amount ⇒ Object
The total amount refunded for an order (Money)
350 351 352 |
# File 'lib/google4r/checkout/notifications.rb', line 350 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.
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/google4r/checkout/notifications.rb', line 360 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 = (BigDecimal.new(element.elements['latest-refund-amount'].text)*100).to_i refund.latest_refund_amount = Money.new(amount, currency) currency = element.elements['total-refund-amount'].attributes['currency'] amount = (BigDecimal.new(element.elements['total-refund-amount'].text)*100).to_i refund.total_refund_amount = Money.new(amount, currency) if element.elements['latest-fee-refund-amount'] currency = element.elements['latest-fee-refund-amount'].attributes['currency'] amount = (BigDecimal.new(element.elements['latest-fee-refund-amount'].text)*100).to_i refund.latest_fee_refund_amount = Money.new(amount, currency) end refund. = Time.parse(element.elements['timestamp'].text) return refund end |