Class: Braspag::Buyer

Inherits:
Handsoap::Service show all
Includes:
Service
Defined in:
lib/braspag/buyer.rb

Instance Method Summary collapse

Methods included from Service

#initialize, #on_create_document, #on_response_document

Instance Method Details

#base_action_urlObject



14
15
16
# File 'lib/braspag/buyer.rb', line 14

def base_action_url
  "https://www.pagador.com.br/webservice/pagador"
end

#buy!(map) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/braspag/buyer.rb', line 5

def buy!(map)
  document = invoke_and_parse('Authorize', "#{base_action_url}/Authorize") do |message|
    map.each do |key, value|
      message.add("tns:#{key}", "#{value}")
    end
  end
  convert_to_map document
end

#convert_to_map(document) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/braspag/buyer.rb', line 22

def convert_to_map(document)
  map = {"amount" => "", "authorisationNumber" => "", "message" => "", "returnCode" => "", "status" => "", "transactionId" => ""}
  map.each_key do |key|
    document.xpath("//ns:#{key}").each do |text|
      map[key] = text.to_s
    end
  end
  map
end

#uriObject



18
19
20
# File 'lib/braspag/buyer.rb', line 18

def uri
  "#{@connection.base_url}/webservices/pagador/Pagador.asmx"
end