Class: Google4R::Checkout::ChargebackAmountNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::ChargebackAmountNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends a <chargeback-amount-notification> when a customer initiates a chargeback against the order and Google approves the chargeback. See the Google Checkout documentation for more details: code.google.com/apis/checkout/developer/index.html#chargeback_amount_notification
Instance Attribute Summary collapse
-
#latest_chargeback_amount ⇒ Object
The amount most recently charged back for an order (Money).
-
#latest_chargeback_fee_amount ⇒ Object
The latest fee for the charge back (Money).
-
#latest_fee_refund_amount ⇒ Object
The latest transaction fee refund for an on order (Money).
-
#total_chargeback_amount ⇒ Object
The total amount charged back 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 ChargebackAmountNotification from an REXML::Element instance.
Methods inherited from Notification
Constructor Details
This class inherits a constructor from Google4R::Checkout::Notification
Instance Attribute Details
#latest_chargeback_amount ⇒ Object
The amount most recently charged back for an order (Money)
393 394 395 |
# File 'lib/google4r/checkout/notifications.rb', line 393 def latest_chargeback_amount @latest_chargeback_amount end |
#latest_chargeback_fee_amount ⇒ Object
The latest fee for the charge back (Money)
399 400 401 |
# File 'lib/google4r/checkout/notifications.rb', line 399 def latest_chargeback_fee_amount @latest_chargeback_fee_amount end |
#latest_fee_refund_amount ⇒ Object
The latest transaction fee refund for an on order (Money)
402 403 404 |
# File 'lib/google4r/checkout/notifications.rb', line 402 def latest_fee_refund_amount @latest_fee_refund_amount end |
#total_chargeback_amount ⇒ Object
The total amount charged back for an order (Money)
396 397 398 |
# File 'lib/google4r/checkout/notifications.rb', line 396 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.
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/google4r/checkout/notifications.rb', line 409 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 = (BigDecimal.new(element.elements['latest-chargeback-amount'].text)*100).to_i chargeback.latest_chargeback_amount = Money.new(amount, currency) currency = element.elements['total-chargeback-amount'].attributes['currency'] amount = (BigDecimal.new(element.elements['total-chargeback-amount'].text)*100).to_i chargeback.total_chargeback_amount = Money.new(amount, currency) if element.elements['latest-chargeback-fee-amount'] currency = element.elements['latest-chargeback-fee-amount'].attributes['currency'] amount = (BigDecimal.new(element.elements['latest-chargeback-fee-amount'].text)*100).to_i chargeback.latest_chargeback_fee_amount = Money.new(amount, currency) end 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 chargeback.latest_fee_refund_amount = Money.new(amount, currency) end chargeback. = Time.parse(element.elements['timestamp'].text) return chargeback end |