Sha256: 9835ef497797b60e829e3c4c0bd865c1b9139537d5cd6c159453bcfa2123d2c2

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 Bytes

Contents

require 'httparty'
require 'builder'

class Datatrans::XML::Transaction
  class Request

    attr_accessor :params, :datatrans

    def post(url, options = {})
      options = options.merge(self.datatrans.proxy)
      HTTParty.post(url, options)
    end

    def initialize(datatrans, params)
      @datatrans = datatrans
      @params = params
    end

    def process
      raise 'overwrite in subclass!'
    end

    private

    include Datatrans::Common

    def build_xml_request(service)
      xml = Builder::XmlMarkup.new
      xml.instruct!
      xml.tag! "#{service}Service", :version => 1 do
        xml.body :merchantId => self.datatrans.merchant_id do |body|
          xml.transaction :refno => params[:refno] do
            xml.request do
              yield body
            end
          end
        end
      end
      xml.target!
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datatrans-3.0.2 lib/datatrans/xml/transaction/request.rb
datatrans-3.0.1 lib/datatrans/xml/transaction/request.rb
datatrans-3.0.0 lib/datatrans/xml/transaction/request.rb