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).
-
#latest_charge_fee ⇒ Object
Returns the value of attribute latest_charge_fee.
-
#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)
305 306 307 |
# File 'lib/google4r/checkout/notifications.rb', line 305 def latest_charge_amount @latest_charge_amount end |
#latest_charge_fee ⇒ Object
Returns the value of attribute latest_charge_fee.
310 311 312 |
# File 'lib/google4r/checkout/notifications.rb', line 310 def latest_charge_fee @latest_charge_fee end |
#total_charge_amount ⇒ Object
The total amount charged for an order (Money)
308 309 310 |
# File 'lib/google4r/checkout/notifications.rb', line 308 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.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/google4r/checkout/notifications.rb', line 317 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 = (BigDecimal.new(element.elements['latest-charge-amount'].text)*100).to_i charge.latest_charge_amount = Money.new(amount, currency) currency = element.elements['total-charge-amount'].attributes['currency'] amount = (BigDecimal.new(element.elements['total-charge-amount'].text)*100).to_i charge.total_charge_amount = Money.new(amount, currency) if element.elements["latest-charge-fee"] charge.latest_charge_fee = ChargeFee.create_from_element(element.elements["latest-charge-fee"]) end charge. = Time.parse(element.elements['timestamp'].text) return charge end |