Class: ActiveMerchant::ClickandBuy::Request::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_merchant/clickand_buy/request/base.rb

Direct Known Subclasses

PayRequest, StatusRequest

Instance Method Summary collapse

Constructor Details

#initialize(auth) ⇒ Base

Returns a new instance of Base.



3
4
5
# File 'lib/active_merchant/clickand_buy/request/base.rb', line 3

def initialize(auth)
  @auth = auth
end

Instance Method Details

#bodyObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_merchant/clickand_buy/request/base.rb', line 7

def body
  xml = Builder::XmlMarkup.new
  xml.instruct!

  xml.SOAP :Envelope, 'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/' do
    xml.SOAP :Body do
      xml.tag! request_tag, xmlns: 'http://api.clickandbuy.com/webservices/pay_1_1_0/' do
        xml.authentication do
          xml.merchantID @auth[:merchant_id]
          xml.projectID @auth[:project_id]
          xml.token token
        end

        xml.details do
          details(xml)
        end
      end
    end
  end

  xml.target!
end

#handle_response(response_string) ⇒ Object



30
31
32
33
# File 'lib/active_merchant/clickand_buy/request/base.rb', line 30

def handle_response(response_string)
  response = Hash.from_xml(response_string)
  extract_response_details(response['Envelope']['Body'][response_tag])
end