Class: ActiveMerchant::Billing::AVSResult

Inherits:
Object
  • Object
show all
Defined in:
lib/active_merchant/billing/avs_result.rb

Overview

Direct Known Subclasses

OrbitalGateway::AVSResult

Constant Summary

MESSAGES =
{
  'A' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
  'B' => 'Street address matches, but postal code not verified.',
  'C' => 'Street address and postal code do not match.',
  'D' => 'Street address and postal code match.',
  'E' => 'AVS data is invalid or AVS is not allowed for this card type.',
  'F' => 'Card member\'s name does not match, but billing postal code matches.',
  'G' => 'Non-U.S. issuing bank does not support AVS.',
  'H' => 'Card member\'s name does not match. Street address and postal code match.',
  'I' => 'Address not verified.',
  'J' => 'Card member\'s name, billing address, and postal code match. Shipping information verified and chargeback protection guaranteed through the Fraud Protection Program.',
  'K' => 'Card member\'s name matches but billing address and billing postal code do not match.',
  'L' => 'Card member\'s name and billing postal code match, but billing address does not match.',
  'M' => 'Street address and postal code match.',
  'N' => 'Street address and postal code do not match.',
  'O' => 'Card member\'s name and billing address match, but billing postal code does not match.',
  'P' => 'Postal code matches, but street address not verified.',
  'Q' => 'Card member\'s name, billing address, and postal code match. Shipping information verified but chargeback protection not guaranteed.',
  'R' => 'System unavailable.',
  'S' => 'U.S.-issuing bank does not support AVS.',
  'T' => 'Card member\'s name does not match, but street address matches.',
  'U' => 'Address information unavailable.',
  'V' => 'Card member\'s name, billing address, and billing postal code match.',
  'W' => 'Street address does not match, but 9-digit postal code matches.',
  'X' => 'Street address and 9-digit postal code match.',
  'Y' => 'Street address and 5-digit postal code match.',
  'Z' => 'Street address does not match, but 5-digit postal code matches.'
}
POSTAL_MATCH_CODE =

Map vendor's AVS result code to a postal match code

{
  'Y' => %w( D H F H J L M P Q V W X Y Z ),
  'N' => %w( A C K N O ),
  'X' => %w( G S ),
  nil => %w( B E I R T U )
}.inject({}) do |map, (type, codes)|
  codes.each { |code| map[code] = type }
  map
end
STREET_MATCH_CODE =

Map vendor's AVS result code to a street match code

{
  'Y' => %w( A B D H J M O Q T V X Y ),
  'N' => %w( C K L N W Z ),
  'X' => %w( G S ),
  nil => %w( E F I P R U )
}.inject({}) do |map, (type, codes)|
  codes.each { |code| map[code] = type }
  map
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ AVSResult



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/active_merchant/billing/avs_result.rb', line 70

def initialize(attrs)
  attrs ||= {}
  
  @code = attrs[:code].upcase unless attrs[:code].blank?
  @message = self.class.messages[code]
  
  if attrs[:street_match].blank?
    @street_match = STREET_MATCH_CODE[code]
  else  
    @street_match = attrs[:street_match].upcase
  end
    
  if attrs[:postal_match].blank?
    @postal_match = POSTAL_MATCH_CODE[code]
  else  
    @postal_match = attrs[:postal_match].upcase
  end
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code



64
65
66
# File 'lib/active_merchant/billing/avs_result.rb', line 64

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message



64
65
66
# File 'lib/active_merchant/billing/avs_result.rb', line 64

def message
  @message
end

#postal_matchObject (readonly)

Returns the value of attribute postal_match



64
65
66
# File 'lib/active_merchant/billing/avs_result.rb', line 64

def postal_match
  @postal_match
end

#street_matchObject (readonly)

Returns the value of attribute street_match



64
65
66
# File 'lib/active_merchant/billing/avs_result.rb', line 64

def street_match
  @street_match
end

Class Method Details

.messagesObject



66
67
68
# File 'lib/active_merchant/billing/avs_result.rb', line 66

def self.messages
  MESSAGES
end

Instance Method Details

#to_hashObject



89
90
91
92
93
94
95
# File 'lib/active_merchant/billing/avs_result.rb', line 89

def to_hash
  { 'code' => code,
    'message' => message,
    'street_match' => street_match,
    'postal_match' => postal_match
  }
end