Class: ActiveMerchant::Billing::BarclaysEpdqGateway::Parser
- Inherits:
-
Object
- Object
- ActiveMerchant::Billing::BarclaysEpdqGateway::Parser
- Defined in:
- lib/active_merchant/billing/gateways/barclays_epdq.rb
Instance Method Summary collapse
- #find(doc, xpath) ⇒ Object
-
#initialize(response) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(response) ⇒ Parser
Returns a new instance of Parser.
132 133 134 |
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 132 def initialize(response) @response = response end |
Instance Method Details
#find(doc, xpath) ⇒ Object
163 164 165 |
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 163 def find(doc, xpath) REXML::XPath.first(doc, xpath).try(:text) end |
#parse ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 136 def parse doc = REXML::Document.new(@response) auth_type = find(doc, "//Transaction/Type").to_s = find(doc, "//Message/Text") if .blank? = 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 => , :transaction_id => find(doc, "//Transaction/Id"), :avs_result => find(doc, "//Transaction/AvsRespCode"), :cvv_result => find(doc, "//Transaction/Cvv2Resp"), :authorization => find(doc, "//OrderFormDoc/Id"), :raw_response => @response } end |