class HeartlandPortico::Response

Attributes

body[R]
operation[R]

Public Class Methods

new(operation, savon_response) click to toggle source
# File lib/heartland_portico.rb, line 127
def initialize(operation, savon_response)
  @operation = operation.to_sym
  @body = savon_response.body[:pos_response][:ver1_0]
end

Public Instance Methods

authorization() click to toggle source
# File lib/heartland_portico.rb, line 132
def authorization
  body[:header][:gateway_txn_id] if success?
end
avs_address() click to toggle source
# File lib/heartland_portico.rb, line 154
def avs_address
  %w(A Y X B D M).include? avs_code
end
avs_code() click to toggle source
# File lib/heartland_portico.rb, line 151
def avs_code
  response[:avs_rslt_code]
end
avs_zip() click to toggle source
# File lib/heartland_portico.rb, line 157
def avs_zip
  %w(Z W Y X D M P).include? avs_code
end
cvv() click to toggle source
# File lib/heartland_portico.rb, line 165
def cvv
  # Valid Values:
  # M: Match
  # N: No Match
  # P: Not Processed
  # S: Should have been present
  # U: Issuer not certified
  cvv_code == "M"
end
cvv_code() click to toggle source
# File lib/heartland_portico.rb, line 161
def cvv_code
  response[:cvv_rslt_code]
end
message() click to toggle source
# File lib/heartland_portico.rb, line 136
def message
  return "ERROR" unless successful_request?
  # CreditAddToBatch has an explicit empty response, with hard errors if not successful
  return "APPROVAL" if body[:transaction].has_key?(operation) and body[:transaction][operation].nil?
  response[:rsp_text] || response[:rsp_message]
end
params()
Alias for: response
response() click to toggle source
# File lib/heartland_portico.rb, line 175
def response
  # Yes, I know that's a lot of edge case handling, but I _really_
  # want that to be a hash.
  body[:transaction][operation] || {} rescue {}
end
Also aliased as: params
success?() click to toggle source
# File lib/heartland_portico.rb, line 143
def success?
  ["APPROVAL", "CARD OK", "Transaction Approved"].include? message
end
successful_request?() click to toggle source
# File lib/heartland_portico.rb, line 147
def successful_request?
  body[:header][:gateway_rsp_msg] == "Success"
end