Module: Beanstreamy::QueryAction

Defined in:
lib/beanstreamy/gateway.rb

Constant Summary collapse

EXTRA_TRANSACTIONS =
{ :query => 'Q' }
CVD_CODES =
ActiveMerchant::Billing::BeanstreamCore::CVD_CODES
AVS_CODES =
ActiveMerchant::Billing::BeanstreamCore::AVS_CODES

Instance Method Summary collapse

Instance Method Details

#query(amount, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/beanstreamy/gateway.rb', line 20

def query(amount, options={})
  requires!(options, :order_id)
  
  post = {}
  add_order_number(post, options[:order_id])
  add_amount(post, amount)
  add_transaction_type(post, :query)
  commit(post)
end

#response_from_query(query_string) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/beanstreamy/gateway.rb', line 10

def response_from_query(query_string)
  response = parse(query_string)
  build_response(success?(response), message_from(response), response,
    :test => test? || response[:authCode] == "TEST",
    :authorization => authorization_from(response),
    :cvv_result => CVD_CODES[response[:cvdId]],
    :avs_result => { :code => (AVS_CODES.include? response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
  )
end