lib/active_merchant/billing/gateways/netbanx.rb in activemerchant-1.119.0 vs lib/active_merchant/billing/gateways/netbanx.rb in activemerchant-1.120.0

- old
+ new

@@ -20,10 +20,26 @@ self.money_format = :cents self.homepage_url = 'https://processing.paysafe.com/' self.display_name = 'Netbanx by PaySafe' + AVS_CODE_CONVERTER = { + 'MATCH' => 'X', + 'MATCH_ADDRESS_ONLY' => 'A', + 'MATCH_ZIP_ONLY' => 'Z', + 'NO_MATCH' => 'N', + 'NOT_PROCESSED' => 'U', + 'UNKNOWN' => 'Q' + } + + CVV_CODE_CONVERTER = { + 'MATCH' => 'M', + 'NO_MATCH' => 'N', + 'NOT_PROCESSED' => 'P', + 'UNKNOWN' => 'U' + } + def initialize(options = {}) requires!(options, :account_number, :api_key) super end @@ -254,12 +270,20 @@ message_from(success, response), response, test: test?, error_code: error_code_from(response), authorization: authorization_from(success, get_url(uri), method, response), - avs_result: AVSResult.new(code: response['avsResponse']), - cvv_result: CVVResult.new(response['cvvVerification']) + avs_result: avs_result(response), + cvv_result: cvv_result(response) ) + end + + def avs_result(response) + AVSResult.new(code: AVS_CODE_CONVERTER[response['avsResponse']]) + end + + def cvv_result(response) + CVVResult.new(CVV_CODE_CONVERTER[response['cvvVerification']]) end def get_url(uri) url = (test? ? test_url : live_url) if /^customervault/.match?(uri)