Class: Google4R::Checkout::ChargebackAmountNotification

Inherits:
Notification
  • Object
show all
Defined in:
lib/google4r/checkout/notifications.rb

Overview

Google Checkout sends a when a customer initiates a chargeback against the order and Google approves the chargeback. See the Google Checkout documentation for more details: http://code.google.com/apis/checkout/developer/index.html#chargeback_amount_notification

Instance Attribute Summary collapse

Attributes inherited from Notification

#frontend, #google_order_number, #serial_number, #timestamp

Class Method Summary collapse

Methods inherited from Notification

#initialize

Constructor Details

This class inherits a constructor from Google4R::Checkout::Notification

Instance Attribute Details

#latest_chargeback_amountObject

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_amountObject

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.timestamp = Time.parse(element.elements['timestamp'].text)

  return chargeback
end