lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.11.0 vs lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.12.0
- old
+ new
@@ -46,10 +46,11 @@
self.homepage_url = 'http://www.authorize.net/'
self.display_name = 'Authorize.Net'
CARD_CODE_ERRORS = %w( N S )
AVS_ERRORS = %w( A E N R W Z )
+ AVS_REASON_CODES = %w(27 45)
AUTHORIZE_NET_ARB_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
RECURRING_ACTIONS = {
:create => 'ARBCreateSubscription',
@@ -368,13 +369,15 @@
end
def message_from(results)
if results[:response_code] == DECLINED
return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
- return AVSResult.messages[ results[:avs_result_code] ] if AVS_ERRORS.include?(results[:avs_result_code])
+ if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
+ return AVSResult.messages[ results[:avs_result_code] ]
+ end
end
- return results[:response_reason_text].nil? ? '' : results[:response_reason_text].chomp('.')
+ (results[:response_reason_text] ? results[:response_reason_text].chomp('.') : '')
end
def expdate(creditcard)
year = sprintf("%.4i", creditcard.year)
month = sprintf("%.2i", creditcard.month)