lib/active_merchant/billing/avs_result.rb in activemerchant-1.85.0 vs lib/active_merchant/billing/avs_result.rb in activemerchant-1.86.0
- old
+ new
@@ -1,10 +1,10 @@
#!ruby19
# encoding: utf-8
module ActiveMerchant
- module Billing
+ module Billing
# Implements the Address Verification System
# https://www.wellsfargo.com/downloads/pdf/biz/merchant/visa_avs.pdf
# http://en.wikipedia.org/wiki/Address_Verification_System
# http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_IG/html/app_avs_cvn_codes.htm#app_AVS_CVN_codes_7891_48375
# http://imgserver.skipjack.com/imgServer/5293710/AVS%20and%20CVV2.pdf
@@ -36,57 +36,57 @@
'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.'
}
-
+
# Map vendor's AVS result code to a postal match code
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
-
+
# Map vendor's AVS result code to a street match code
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
-
+
attr_reader :code, :message, :street_match, :postal_match
-
+
def self.messages
MESSAGES
end
-
+
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
+ else
@street_match = attrs[:street_match].upcase
end
-
+
if attrs[:postal_match].blank?
@postal_match = POSTAL_MATCH_CODE[code]
- else
+ else
@postal_match = attrs[:postal_match].upcase
end
end
-
+
def to_hash
{ 'code' => code,
'message' => message,
'street_match' => street_match,
'postal_match' => postal_match