Sha256: a6f3dc0053e6642464f4c119dcf23d88e39524d2f3addccdeff88a962266599e

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'httparty'
require 'builder'

class Datatrans::XML::Transaction
  class Request
    include HTTParty

    attr_accessor :params

    def self.set_default_options
      if Datatrans.proxy
        proxy = Datatrans.proxy.symbolize_keys
        http_proxy(proxy[:host], proxy[:port], proxy[:user], proxy[:password])
      else
        http_proxy(nil, nil, nil, nil)
      end
    end

    def self.perform_request(*args, &block)
      set_default_options
      super
    end

    def initialize(params)
      @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 => 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

1 entries across 1 versions & 1 rubygems

Version Path
datatrans-2.4.0 lib/datatrans/xml/transaction/request.rb