Class: Payline::ResponseHandler
- Inherits:
-
Object
- Object
- Payline::ResponseHandler
- Defined in:
- lib/payline/response_handler.rb
Instance Method Summary collapse
Instance Method Details
#handle_errors(hash) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/payline/response_handler.rb', line 19 def handle_errors(hash) if hash['PROCESSING.REASON.CODE'].to_s != '00' # Error message should be friendly raise Payline::Error.new(hash['PROCESSING.RETURN'], hash) end end |
#parse(text) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/payline/response_handler.rb', line 4 def parse(text) # CGI by default returns an hash of arrays even if there is one element (is is the norm) hash = CGI::parse(text) hash.each {|k, v| hash[k] = v.length == 1 ? v.first : v } hash end |
#parse_and_handle_errors(text) ⇒ Object
13 14 15 16 17 |
# File 'lib/payline/response_handler.rb', line 13 def parse_and_handle_errors(text) hash = parse(text) handle_errors(hash) hash end |