lib/active_merchant/billing/gateways/transbank_oneclick.rb
def body_to_params(doc)
        params = {}
        body = doc.xpath('/soap:Envelope/soap:Body', 'soap' => SOAP_NAMESPACE).first
        ret = body.xpath('//return').first
        if ret
          if ret.content =~ /true|false/
            # From commands: reverse, removeUser
            params['success'] = (ret.content == 'true')
          else
            # From commands: initInscription, finishInscription, authorize
            ret.children.each do |child|
              unless child.name.blank?
                params[child.name.to_s] = child.content
              end
            end
            params['message'] = RESPONSE_TEXTS[params['responseCode']]
            params['success'] = params['token'] ? true : (params['responseCode'] == "0")
          end
        else
          # Something is very wrong
          fault = body.xpath('//faultstring').first
          params['success'] = false
          params['message']   = fault ? fault.content : "Unknown fault"
        end
        params
      end
# Convert the body into a hash of params and try to determine if we were successful
Convert the body into a hash of params and try to determine if we were successful
Convert the body into a hash of params and try to determine if we were successful
def body_to_params(doc)
        params = {}
        body = doc.xpath('/soap:Envelope/soap:Body', 'soap' => SOAP_NAMESPACE).first
        ret = body.xpath('//return').first
        if ret
          if ret.content =~ /true|false/
            params['success'] = (ret.content == 'true')
          else
            ret.children.each do |child|
              unless child.name.blank?
                params[child.name.to_s] = child.content
              end
            end
            params['message'] = RESPONSE_TEXTS[params['responseCode']]
            params['success'] = params['token'] ? true : (params['responseCode'] == "0")
          end
        else
          fault = body.xpath('//faultstring').first
          params['success'] = false
          params['message']   = fault ? fault.content : "Unknown fault"
        end
        params
      end
def body_to_params ( doc ) params = { } body = doc . xpath ( '/soap:Envelope/soap:Body' , 'soap' => SOAP_NAMESPACE ) . first ret = body . xpath ( '//return' ) . first if ret if ret . content =~ / true|false / params [ 'success' ] = ( ret . content == 'true' ) else ret . children . each do | child | unless child . name . blank? params [ child . name . to_s ] = child . content end end params [ 'message' ] = RESPONSE_TEXTS [ params [ 'responseCode' ] ] params [ 'success' ] = params [ 'token' ] ? true : ( params [ 'responseCode' ] == "0" ) end else fault = body . xpath ( '//faultstring' ) . first params [ 'success' ] = false params [ 'message' ] = fault ? fault . content : "Unknown fault" end params end
Convert the body into a hash of params and try to determine if we were successful
Convert the body into a hash of params and try to determine if we were successful
# From commands: reverse, removeUser # From commands: initInscription, finishInscription, authorize # Something is very wrong
doc