Class: Google4R::Checkout::AuthorizationAmountNotification

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

Overview

Google Checkout sends an <authorization-amount-notification> in response to a successful request for an explicit credit card reauthorization. See the Google Checkout documentation for more details: code.google.com/apis/checkout/developer/index.html#authorization_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

#authorization_amountObject

The amount that is reauthorized to be charged to the customer’s credit card (Money)



448
449
450
# File 'lib/google4r/checkout/notifications.rb', line 448

def authorization_amount
  @authorization_amount
end

#authorization_expiration_dateObject

The time that a credit card authorization for an order expires.



451
452
453
# File 'lib/google4r/checkout/notifications.rb', line 451

def authorization_expiration_date
  @authorization_expiration_date
end

#avs_responseObject

The address verification response (String)



454
455
456
# File 'lib/google4r/checkout/notifications.rb', line 454

def avs_response
  @avs_response
end

#cvn_responseObject

Credit verification value for the order (String)



457
458
459
# File 'lib/google4r/checkout/notifications.rb', line 457

def cvn_response
  @cvn_response
end

Class Method Details

.create_from_element(element, frontend) ⇒ Object

Factory method that creates a new AuthorizationAmountNotification from an REXML::Element instance. Use this to create instances of AuthorizationAmountNotification.

Raises NoMethodError and RuntimeError exceptions if the given element misses required elements.



464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/google4r/checkout/notifications.rb', line 464

def self.create_from_element(element, frontend)
  authorization = AuthorizationAmountNotification.new(frontend)
  
  authorization.serial_number = element.attributes['serial-number']
  authorization.google_order_number = element.elements['google-order-number'].text
  
  currency = element.elements['authorization-amount'].attributes['currency']
  amount = (BigDecimal.new(element.elements['authorization-amount'].text)*100).to_i
  authorization.authorization_amount = Money.new(amount, currency)

  authorization.authorization_expiration_date = Time.parse(element.elements['authorization-expiration-date'].text)
  
  authorization.avs_response = element.elements['avs-response'].text
  authorization.cvn_response = element.elements['cvn-response'].text
  
  authorization.timestamp = Time.parse(element.elements['timestamp'].text)

  return authorization
end