Class: Google4R::Checkout::AuthorizationAmountNotification

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

Overview

Google Checkout sends an in response to a successful request for an explicit credit card reauthorization. See the Google Checkout documentation for more details: http://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)



404
405
406
# File 'lib/google4r/checkout/notifications.rb', line 404

def authorization_amount
  @authorization_amount
end

#authorization_expiration_dateObject

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



407
408
409
# File 'lib/google4r/checkout/notifications.rb', line 407

def authorization_expiration_date
  @authorization_expiration_date
end

#avs_responseObject

The address verification response (String)



410
411
412
# File 'lib/google4r/checkout/notifications.rb', line 410

def avs_response
  @avs_response
end

#cvn_responseObject

Credit verification value for the order (String)



413
414
415
# File 'lib/google4r/checkout/notifications.rb', line 413

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.



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 420

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 = (element.elements['authorization-amount'].text.to_f*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