Parent

Methods

Class/Module Index [+]

Quicksearch

ActiveMerchant::Billing::BarclaysEpdqGateway::Parser

Public Class Methods

new(response) click to toggle source
# File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 133
def initialize(response)
  @response = response
end

Public Instance Methods

find(doc, xpath) click to toggle source
# File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 164
def find(doc, xpath)
  REXML::XPath.first(doc, xpath).try(:text)
end
parse() click to toggle source
# File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 137
def parse
  doc = REXML::Document.new(@response)
  auth_type = find(doc, "//Transaction/Type").to_s

  message = find(doc, "//Message/Text")
  if message.blank?
    message = find(doc, "//Transaction/CardProcResp/CcReturnMsg")
  end

  case auth_type
  when 'Credit', 'Void'
    success = find(doc, "//CcReturnMsg") == "Approved."
  else
    success = find(doc, "//Transaction/AuthCode").present?
  end

  {       
    :success => success,
    :message => message,
    :authorization => find(doc, "//Transaction/Id"),
    :avs_result => find(doc, "//Transaction/AvsRespCode"),
    :cvv_result => find(doc, "//Transaction/Cvv2Resp"),
    :order_id => find(doc, "//OrderFormDoc/Transaction/Id"),
    :raw_response => @response
  }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.