activepayment 0.0.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rvmrc +1 -1
 - data/Gemfile +11 -2
 - data/README.rdoc +7 -1
 - data/activepayment.gemspec +0 -10
 - data/lib/activepayment/gateway_base.rb +41 -0
 - data/lib/activepayment/payone/gateway.rb +75 -0
 - data/lib/activepayment/payone/response.rb +41 -0
 - data/lib/activepayment/railtie.rb +4 -1
 - data/lib/activepayment/version.rb +1 -1
 - data/lib/activepayment/wirecard/gateway.rb +16 -39
 - data/lib/activepayment/wirecard/response.rb +60 -0
 - data/lib/activepayment.rb +7 -1
 - data/spec/fixtures/activepayment_config.yml +5 -0
 - data/spec/fixtures/payone/gateway/authorization_request.txt +1 -0
 - data/spec/fixtures/payone/gateway/successful_authorization_response.txt +3 -0
 - data/spec/functional/payone_spec.rb +75 -0
 - data/spec/unit/gateway_base_spec.rb +5 -0
 - data/spec/unit/payone/gateway_spec.rb +128 -0
 - data/spec/unit/payone/response_spec.rb +21 -0
 - data/spec/unit/{response_spec.rb → wirecard/response_spec.rb} +2 -2
 - metadata +14 -93
 - data/lib/activepayment/response.rb +0 -58
 
    
        data/.rvmrc
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            rvm --create use 1.9.2- 
     | 
| 
      
 1 
     | 
    
         
            +
            rvm --create use 1.9.2-p290
         
     | 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -1,4 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            source "http://rubygems.org"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            gem 'activesupport'
         
     | 
| 
      
 4 
     | 
    
         
            +
            gem 'nokogiri'
         
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'builder'
         
     | 
| 
      
 6 
     | 
    
         
            +
            gem 'money'
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem 'uuid'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            group :development, :test do
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem 'rake'
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem 'rspec'
         
     | 
| 
      
 12 
     | 
    
         
            +
              gem 'forgery'
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
    
        data/README.rdoc
    CHANGED
    
    
    
        data/activepayment.gemspec
    CHANGED
    
    | 
         @@ -17,14 +17,4 @@ Gem::Specification.new do |s| 
     | 
|
| 
       17 
17 
     | 
    
         
             
              s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
       18 
18 
     | 
    
         
             
              s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
         
     | 
| 
       19 
19 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              s.add_dependency 'activesupport'
         
     | 
| 
       22 
     | 
    
         
            -
              s.add_dependency 'nokogiri'
         
     | 
| 
       23 
     | 
    
         
            -
              s.add_dependency 'builder'
         
     | 
| 
       24 
     | 
    
         
            -
              s.add_dependency 'money'
         
     | 
| 
       25 
     | 
    
         
            -
              s.add_dependency 'uuid'
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              s.add_development_dependency 'rake'
         
     | 
| 
       28 
     | 
    
         
            -
              s.add_development_dependency 'rspec'
         
     | 
| 
       29 
     | 
    
         
            -
              s.add_development_dependency 'forgery'
         
     | 
| 
       30 
20 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActivePayment
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Gateway
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Base
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  class_attribute :gateway_name, :test_url, :live_url, :default_currency
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_accessor :transaction_params
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def self.build(name)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    "ActivePayment::#{name.to_s.classify}::Gateway".constantize
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  def self.config=(config)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    config = config[self.gateway_name] if config.include?(self.gateway_name) && !config[self.gateway_name].blank?
         
     | 
| 
      
 15 
     | 
    
         
            +
                    config.each { |method, value| self.send("#{method}=", value) }
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def self.config
         
     | 
| 
      
 19 
     | 
    
         
            +
                    yield self
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def url
         
     | 
| 
      
 23 
     | 
    
         
            +
                    if  self.mode.blank? || self.mode.eql?('demo') || self.mode.eql?('test')
         
     | 
| 
      
 24 
     | 
    
         
            +
                      URI.parse self.test_url
         
     | 
| 
      
 25 
     | 
    
         
            +
                    else
         
     | 
| 
      
 26 
     | 
    
         
            +
                      URI.parse self.live_url
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  def http_connection
         
     | 
| 
      
 31 
     | 
    
         
            +
                    http = Net::HTTP.new(self.url.host, self.url.port)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    unless http.blank?
         
     | 
| 
      
 33 
     | 
    
         
            +
                      http.use_ssl = true
         
     | 
| 
      
 34 
     | 
    
         
            +
                      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
         
     | 
| 
      
 35 
     | 
    
         
            +
                      yield http
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,75 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActivePayment
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Payone
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Gateway < ActivePayment::Gateway::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  class_attribute :mid, :portalid, :key, :mode
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                  self.gateway_name = "payone"
         
     | 
| 
      
 8 
     | 
    
         
            +
                  self.test_url = 'https://api.pay1.de/post-gateway/'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  self.live_url = ''
         
     | 
| 
      
 10 
     | 
    
         
            +
                  self.default_currency = 'EUR'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  private
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def self.define_request(name, options = {})
         
     | 
| 
      
 15 
     | 
    
         
            +
                    define_method(name) do |local_params = {}|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      post_request(self.send("#{name}_request", local_params))
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                    define_method("#{name}_request") do |local_params = {}|
         
     | 
| 
      
 19 
     | 
    
         
            +
                      request_method = options[:request_method].blank? ? name : options[:request_method]
         
     | 
| 
      
 20 
     | 
    
         
            +
                      build_request(request_method, options) do |params|
         
     | 
| 
      
 21 
     | 
    
         
            +
                        params.merge!(local_params)
         
     | 
| 
      
 22 
     | 
    
         
            +
                      end
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  public
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  define_request :authorization, :obligation_params => [:aid, :amount, :currency, :reference], :default => {:currency => self.default_currency}
         
     | 
| 
      
 29 
     | 
    
         
            +
                  define_request :createaccess, :obligation_params => [:aid, :reference]
         
     | 
| 
      
 30 
     | 
    
         
            +
                  define_request :updateuser, :obligation_params => [:userid]
         
     | 
| 
      
 31 
     | 
    
         
            +
                  define_request :updateaccess, :obligation_params => [:accessid, :action]
         
     | 
| 
      
 32 
     | 
    
         
            +
                  define_request :threedscheck, :request_method => '3dscheck', :obligation_params => [:aid], :default => {:currency => self.default_currency}
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  private
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  def add_optional_param(params, name, value = nil)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    if value.blank? && self.transaction_params.include?(name) && !self.transaction_params[name].blank?
         
     | 
| 
      
 38 
     | 
    
         
            +
                      value = self.transaction_params[name]
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                    unless value.blank?
         
     | 
| 
      
 41 
     | 
    
         
            +
                      params[name] = value
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  def build_request(method, options = {}, &block)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    params = {:mid => self.mid, :portalid => self.portalid, :key => Digest::MD5.new.hexdigest(self.key), :mode => self.mode, :request => method}
         
     | 
| 
      
 47 
     | 
    
         
            +
                    params.merge!(options[:default]) if options[:default]
         
     | 
| 
      
 48 
     | 
    
         
            +
                    params.merge!(self.transaction_params) if self.transaction_params
         
     | 
| 
      
 49 
     | 
    
         
            +
                    yield params
         
     | 
| 
      
 50 
     | 
    
         
            +
                    check_params(params, options[:obligation_params]) if options[:obligation_params]
         
     | 
| 
      
 51 
     | 
    
         
            +
                    params.to_query
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  def check_params(params, obligation_params)
         
     | 
| 
      
 55 
     | 
    
         
            +
                    obligation_params.each do |obligation_param|
         
     | 
| 
      
 56 
     | 
    
         
            +
                      if !params.include?(obligation_param)
         
     | 
| 
      
 57 
     | 
    
         
            +
                        raise Exception, "Payone API Parameters not complete: #{obligation_param} not exists"
         
     | 
| 
      
 58 
     | 
    
         
            +
                      elsif params[obligation_param].blank?
         
     | 
| 
      
 59 
     | 
    
         
            +
                        raise Exception, "Payone API Parameters not complete: #{obligation_param} is nil or empty"
         
     | 
| 
      
 60 
     | 
    
         
            +
                      end
         
     | 
| 
      
 61 
     | 
    
         
            +
                    end
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  def post_request(content)
         
     | 
| 
      
 65 
     | 
    
         
            +
                    http_connection do |http|
         
     | 
| 
      
 66 
     | 
    
         
            +
                      response = http.post(self.url.path, content, {'Content-Type'=> 'application/x-www-form-urlencoded'})
         
     | 
| 
      
 67 
     | 
    
         
            +
                      unless response.blank?
         
     | 
| 
      
 68 
     | 
    
         
            +
                        return ActivePayment::Payone::Response.new(response.body)
         
     | 
| 
      
 69 
     | 
    
         
            +
                      end
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActivePayment
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Payone
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Response
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  def initialize(content)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    @content = content
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @content.to_s
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  def [](key)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @content.split("\n").each do |param|
         
     | 
| 
      
 15 
     | 
    
         
            +
                      param_key, param_value = param.scan(/([^=]+)=(.+)/).first
         
     | 
| 
      
 16 
     | 
    
         
            +
                      if param_key.eql?(key.to_s)
         
     | 
| 
      
 17 
     | 
    
         
            +
                        return param_value
         
     | 
| 
      
 18 
     | 
    
         
            +
                      end
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def successful?
         
     | 
| 
      
 23 
     | 
    
         
            +
                    self.status.eql?('APPROVED') || self.status.eql?('REDIRECT') || self.status.eql?('OK')
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  def failed?
         
     | 
| 
      
 27 
     | 
    
         
            +
                    self.status.eql?('ERROR')
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  def method_missing(method, *args)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    value = self[method]
         
     | 
| 
      
 32 
     | 
    
         
            +
                    unless value.blank?
         
     | 
| 
      
 33 
     | 
    
         
            +
                      value
         
     | 
| 
      
 34 
     | 
    
         
            +
                    else
         
     | 
| 
      
 35 
     | 
    
         
            +
                      super
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -4,7 +4,10 @@ module ActivePayment 
     | 
|
| 
       4 
4 
     | 
    
         
             
                initializer "setup payment" do
         
     | 
| 
       5 
5 
     | 
    
         
             
                  config_file = Rails.root.join("config", "activepayment.yml")
         
     | 
| 
       6 
6 
     | 
    
         
             
                  if config_file.file?
         
     | 
| 
       7 
     | 
    
         
            -
                     
     | 
| 
      
 7 
     | 
    
         
            +
                    gateways = YAML.load(ERB.new(config_file.read).result)[Rails.env]
         
     | 
| 
      
 8 
     | 
    
         
            +
                    gateways.each do |gateway, config|
         
     | 
| 
      
 9 
     | 
    
         
            +
                      ActivePayment::Gateway::Base.build(gateway).config = config
         
     | 
| 
      
 10 
     | 
    
         
            +
                    end
         
     | 
| 
       8 
11 
     | 
    
         
             
                  end
         
     | 
| 
       9 
12 
     | 
    
         
             
                end
         
     | 
| 
       10 
13 
     | 
    
         | 
| 
         @@ -1,38 +1,20 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module ActivePayment
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Wirecard
         
     | 
| 
       3 
     | 
    
         
            -
                class Gateway
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Gateway < ActivePayment::Gateway::Base
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
       6 
     | 
    
         
            -
                  LIVE_URL = 'https://c3.wirecard.com/secure/ssl-gateway'
         
     | 
| 
      
 5 
     | 
    
         
            +
                  class_attribute :login, :password, :signature, :mode
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  attr_accessor : 
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_accessor :amount, :transaction_id, :jop_id
         
     | 
| 
       9 
8 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                    def url
         
     | 
| 
       14 
     | 
    
         
            -
                      if  self.mode.blank? || self.mode.eql?('demo')
         
     | 
| 
       15 
     | 
    
         
            -
                        TEST_URL
         
     | 
| 
       16 
     | 
    
         
            -
                      else
         
     | 
| 
       17 
     | 
    
         
            -
                        LIVE_URL
         
     | 
| 
       18 
     | 
    
         
            -
                      end
         
     | 
| 
       19 
     | 
    
         
            -
                    end
         
     | 
| 
       20 
     | 
    
         
            -
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  self.gateway_name = "wirecard"
         
     | 
| 
      
 10 
     | 
    
         
            +
                  self.test_url = 'https://c3-test.wirecard.com/secure/ssl-gateway'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  self.live_url = 'https://c3.wirecard.com/secure/ssl-gateway'
         
     | 
| 
       21 
12 
     | 
    
         | 
| 
       22 
13 
     | 
    
         
             
                  def initialize(transaction_id, amount)
         
     | 
| 
       23 
14 
     | 
    
         
             
                    @transaction_id = transaction_id
         
     | 
| 
       24 
15 
     | 
    
         
             
                    @amount = amount
         
     | 
| 
       25 
16 
     | 
    
         
             
                  end
         
     | 
| 
       26 
17 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                  def self.config=(config)
         
     | 
| 
       28 
     | 
    
         
            -
                    config = config["wirecard"] if config.include?("wirecard") && !config["wirecard"].blank?
         
     | 
| 
       29 
     | 
    
         
            -
                    config.each { |method, value| self.send("#{method}=", value) }
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                  def self.config
         
     | 
| 
       33 
     | 
    
         
            -
                    yield self
         
     | 
| 
       34 
     | 
    
         
            -
                  end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
18 
     | 
    
         
             
                  public
         
     | 
| 
       37 
19 
     | 
    
         | 
| 
       38 
20 
     | 
    
         
             
                  def authorization(credit_card)
         
     | 
| 
         @@ -148,21 +130,16 @@ module ActivePayment 
     | 
|
| 
       148 
130 
     | 
    
         
             
                  end
         
     | 
| 
       149 
131 
     | 
    
         | 
| 
       150 
132 
     | 
    
         
             
                  def post_request(xml)
         
     | 
| 
       151 
     | 
    
         
            -
                     
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
                       
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
                         
     | 
| 
       156 
     | 
    
         
            -
                        request 
     | 
| 
       157 
     | 
    
         
            -
                         
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
                           
     | 
| 
       161 
     | 
    
         
            -
                          request.body = xml
         
     | 
| 
       162 
     | 
    
         
            -
                          response = http.request(request)
         
     | 
| 
       163 
     | 
    
         
            -
                          if response
         
     | 
| 
       164 
     | 
    
         
            -
                            return Response.new(response.body)
         
     | 
| 
       165 
     | 
    
         
            -
                          end
         
     | 
| 
      
 133 
     | 
    
         
            +
                    http_connection do |http|
         
     | 
| 
      
 134 
     | 
    
         
            +
                      request = Net::HTTP::Post.new(self.url.path)
         
     | 
| 
      
 135 
     | 
    
         
            +
                      unless request.blank?
         
     | 
| 
      
 136 
     | 
    
         
            +
                        request.content_type = "text/xml"
         
     | 
| 
      
 137 
     | 
    
         
            +
                        request.content_length = xml.size
         
     | 
| 
      
 138 
     | 
    
         
            +
                        request.basic_auth(Gateway.login, Gateway.password)
         
     | 
| 
      
 139 
     | 
    
         
            +
                        request.body = xml
         
     | 
| 
      
 140 
     | 
    
         
            +
                        response = http.request(request)
         
     | 
| 
      
 141 
     | 
    
         
            +
                        if response
         
     | 
| 
      
 142 
     | 
    
         
            +
                          return Response.new(response.body)
         
     | 
| 
       166 
143 
     | 
    
         
             
                        end
         
     | 
| 
       167 
144 
     | 
    
         
             
                      end
         
     | 
| 
       168 
145 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -0,0 +1,60 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActivePayment
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Wirecard
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Response
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  def initialize(xml)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    @doc = Nokogiri::XML(xml)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    if @doc.at_css('WIRECARD_BXML').nil?
         
     | 
| 
      
 8 
     | 
    
         
            +
                      raise ActivePayment::Exception, "No valid response"
         
     | 
| 
      
 9 
     | 
    
         
            +
                    end
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @doc.to_s
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def ok?
         
     | 
| 
      
 17 
     | 
    
         
            +
                    return_code.to_i.eql?(0)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def [](node_name)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    parse(@doc.at_css(node_name).content)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def successful?
         
     | 
| 
      
 25 
     | 
    
         
            +
                    self.function_result.eql?('ACK') || self.function_result.eql?('PENDING')
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def failed?
         
     | 
| 
      
 29 
     | 
    
         
            +
                    self.function_result.eql?('NOK')
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  public
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def method_missing(method, *args)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    node_name = method.to_node_name
         
     | 
| 
      
 36 
     | 
    
         
            +
                    unless node_name.blank?
         
     | 
| 
      
 37 
     | 
    
         
            +
                      node = @doc.at_css(node_name)
         
     | 
| 
      
 38 
     | 
    
         
            +
                      unless node.nil?
         
     | 
| 
      
 39 
     | 
    
         
            +
                        parse(@doc.at_css(node_name).content)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      else
         
     | 
| 
      
 41 
     | 
    
         
            +
                        super
         
     | 
| 
      
 42 
     | 
    
         
            +
                      end
         
     | 
| 
      
 43 
     | 
    
         
            +
                    else
         
     | 
| 
      
 44 
     | 
    
         
            +
                      super
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  private
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  def parse(value)
         
     | 
| 
      
 51 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 52 
     | 
    
         
            +
                      return Integer(value)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    rescue
         
     | 
| 
      
 54 
     | 
    
         
            +
                      return value
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/activepayment.rb
    CHANGED
    
    | 
         @@ -3,6 +3,7 @@ require "bundler/setup" 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'uri'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'net/http'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'net/https'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'digest/md5'
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            require "active_support/core_ext"
         
     | 
| 
       8 
9 
     | 
    
         
             
            require "builder"
         
     | 
| 
         @@ -12,9 +13,14 @@ require "uuid" 
     | 
|
| 
       12 
13 
     | 
    
         | 
| 
       13 
14 
     | 
    
         
             
            require "activepayment/railtie" if defined?(Rails)
         
     | 
| 
       14 
15 
     | 
    
         
             
            require "activepayment/version"
         
     | 
| 
       15 
     | 
    
         
            -
            require "activepayment/ 
     | 
| 
      
 16 
     | 
    
         
            +
            require "activepayment/gateway_base"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            require "activepayment/payone/gateway"
         
     | 
| 
       16 
19 
     | 
    
         
             
            require "activepayment/wirecard/gateway"
         
     | 
| 
       17 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
            require "activepayment/payone/response"
         
     | 
| 
      
 22 
     | 
    
         
            +
            require "activepayment/wirecard/response"
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       18 
24 
     | 
    
         
             
            module ActivePayment
         
     | 
| 
       19 
25 
     | 
    
         
             
              class Exception < RuntimeError
         
     | 
| 
       20 
26 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            aid=18270&amount=100&cardcvc2=233&cardexpiredate=1202&cardholder=John+Doe&cardpan=4901170005495083&cardtype=V&clearingtype=cc¤cy=EUR&key=0&mid=18268&mode=test&portalid=2226&reference=00000000000000000001&request=authorization
         
     | 
| 
         @@ -0,0 +1,75 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe ActivePayment::Payone::Gateway do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              let(:amount) { 100 }
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:gateway) { ActivePayment::Payone::Gateway.new(amount) }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                gateway.transaction_params = {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    :aid => 18270,
         
     | 
| 
      
 11 
     | 
    
         
            +
                    :clearingtype => 'cc',
         
     | 
| 
      
 12 
     | 
    
         
            +
                    :cardholder => "John Doe",
         
     | 
| 
      
 13 
     | 
    
         
            +
                    :cardexpiredate => "#{(Date.today + 1.year).strftime("%y")}02",
         
     | 
| 
      
 14 
     | 
    
         
            +
                    :cardtype => "V",
         
     | 
| 
      
 15 
     | 
    
         
            +
                    :cardpan => "4111111111111111",
         
     | 
| 
      
 16 
     | 
    
         
            +
                    :cardcvc2 => 233,
         
     | 
| 
      
 17 
     | 
    
         
            +
                    :lastname => 'Doe',
         
     | 
| 
      
 18 
     | 
    
         
            +
                    :firstname => 'John',
         
     | 
| 
      
 19 
     | 
    
         
            +
                    :country => 'DE',
         
     | 
| 
      
 20 
     | 
    
         
            +
                    :productid => 4893,
         
     | 
| 
      
 21 
     | 
    
         
            +
                    :amount => amount,
         
     | 
| 
      
 22 
     | 
    
         
            +
                    :reference => 'test'
         
     | 
| 
      
 23 
     | 
    
         
            +
                }
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              describe "Portal Zugang" do
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                let(:payone_response) { gateway.createaccess(:reference => Time.now.to_i + rand(10000)) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                let(:payone_user_id) { payone_response.userid }
         
     | 
| 
      
 30 
     | 
    
         
            +
                let(:payone_access_id) { payone_response.accessid }
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 33 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mid = 18268
         
     | 
| 
      
 34 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.portalid = 2226
         
     | 
| 
      
 35 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.key = 'test'
         
     | 
| 
      
 36 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mode = 'test'
         
     | 
| 
      
 37 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.default_currency = 'EUR'
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                it "should post createaccess request" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  response = gateway.createaccess(:reference => Time.now.to_i + rand(10000))
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  response.successful?.should be_true
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                it "should post updateuser request" do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  response = gateway.updateuser(:userid => payone_user_id, :street => "teststr.1")
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  response.successful?.should be_true
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                it "should post updateaccess request" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                  response = gateway.updateaccess(:accessid => payone_access_id, :action => 'update')
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  response.successful?.should be_true
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              describe "Portal Shop" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 61 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mid = 18268
         
     | 
| 
      
 62 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.portalid = 2013125
         
     | 
| 
      
 63 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.key = 'test'
         
     | 
| 
      
 64 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mode = 'test'
         
     | 
| 
      
 65 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.default_currency = 'EUR'
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                it "should post authorization request" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                  response = gateway.authorization(:reference => Time.now.to_i + rand(10000))
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                  response.successful?.should be_true
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,128 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe ActivePayment::Payone::Gateway do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              let(:amount) { 100 }
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:gateway) { ActivePayment::Payone::Gateway.new(amount) }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                ActivePayment::Payone::Gateway.mid = 18268
         
     | 
| 
      
 10 
     | 
    
         
            +
                ActivePayment::Payone::Gateway.portalid = 2226
         
     | 
| 
      
 11 
     | 
    
         
            +
                ActivePayment::Payone::Gateway.key = 'test'
         
     | 
| 
      
 12 
     | 
    
         
            +
                ActivePayment::Payone::Gateway.mode = "test"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                gateway.transaction_params = {
         
     | 
| 
      
 15 
     | 
    
         
            +
                    :aid => 18270,
         
     | 
| 
      
 16 
     | 
    
         
            +
                    :productid => 123,
         
     | 
| 
      
 17 
     | 
    
         
            +
                    :clearingtype => 'cc',
         
     | 
| 
      
 18 
     | 
    
         
            +
                    :cardholder => "John Doe",
         
     | 
| 
      
 19 
     | 
    
         
            +
                    :cardexpiredate => "1202",
         
     | 
| 
      
 20 
     | 
    
         
            +
                    :cardtype => "V",
         
     | 
| 
      
 21 
     | 
    
         
            +
                    :cardpan => "4901170005495083",
         
     | 
| 
      
 22 
     | 
    
         
            +
                    :cardcvc2 => 233,
         
     | 
| 
      
 23 
     | 
    
         
            +
                    :reference => "00000000000000000001",
         
     | 
| 
      
 24 
     | 
    
         
            +
                    :amount => amount
         
     | 
| 
      
 25 
     | 
    
         
            +
                }
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              it "should build authorization request" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                request = gateway.authorization_request
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                request.should_not be_blank
         
     | 
| 
      
 32 
     | 
    
         
            +
                request.should include('request=authorization')
         
     | 
| 
      
 33 
     | 
    
         
            +
                request.should include('aid=18270')
         
     | 
| 
      
 34 
     | 
    
         
            +
                request.should include('clearingtype=cc')
         
     | 
| 
      
 35 
     | 
    
         
            +
                request.should include('reference=00000000000000000001')
         
     | 
| 
      
 36 
     | 
    
         
            +
                request.should include('amount=100')
         
     | 
| 
      
 37 
     | 
    
         
            +
                request.should include('currency=EUR')
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              it "should build createaccess request" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                request = gateway.createaccess_request
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                request.should_not be_blank
         
     | 
| 
      
 44 
     | 
    
         
            +
                request.should include('request=createaccess')
         
     | 
| 
      
 45 
     | 
    
         
            +
                request.should include('aid=18270')
         
     | 
| 
      
 46 
     | 
    
         
            +
                request.should include('clearingtype=cc')
         
     | 
| 
      
 47 
     | 
    
         
            +
                request.should include('reference=00000000000000000001')
         
     | 
| 
      
 48 
     | 
    
         
            +
                request.should include('productid=123')
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              it "should build updateuser request" do
         
     | 
| 
      
 52 
     | 
    
         
            +
                request = gateway.updateuser_request(:userid => 123)
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                request.should_not be_blank
         
     | 
| 
      
 55 
     | 
    
         
            +
                request.should include('request=updateuser')
         
     | 
| 
      
 56 
     | 
    
         
            +
                request.should include('userid=123')
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              it "should build updateaccess request" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                request = gateway.updateaccess_request(:accessid => 123, :action => 'update')
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                request.should_not be_blank
         
     | 
| 
      
 63 
     | 
    
         
            +
                request.should include('request=updateaccess')
         
     | 
| 
      
 64 
     | 
    
         
            +
                request.should include('accessid=123')
         
     | 
| 
      
 65 
     | 
    
         
            +
                request.should include('action=update')
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              it "should build 3dscheck request" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                request = gateway.threedscheck_request(:cardpan => "4111111111111111", :exiturl => "http://www.example.com")
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                request.should_not be_blank
         
     | 
| 
      
 72 
     | 
    
         
            +
                request.should include('request=3dscheck')
         
     | 
| 
      
 73 
     | 
    
         
            +
                request.should include('amount=100')
         
     | 
| 
      
 74 
     | 
    
         
            +
                request.should include('currency=EUR')
         
     | 
| 
      
 75 
     | 
    
         
            +
                request.should include('clearingtype=cc')
         
     | 
| 
      
 76 
     | 
    
         
            +
                request.should include('exiturl=http%3A%2F%2Fwww.example.com')
         
     | 
| 
      
 77 
     | 
    
         
            +
                request.should include('cardpan=4111111111111111')
         
     | 
| 
      
 78 
     | 
    
         
            +
                request.should include('cardtype=V')
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              it "should get exception if forget mandatory parameter" do
         
     | 
| 
      
 82 
     | 
    
         
            +
                gateway.transaction_params.delete(:reference)
         
     | 
| 
      
 83 
     | 
    
         
            +
                lambda { gateway.createaccess_request }.should raise_exception(ActivePayment::Exception, "Payone API Parameters not complete: reference not exists")
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              describe "config" do
         
     | 
| 
      
 87 
     | 
    
         
            +
                it 'should set by methods' do
         
     | 
| 
      
 88 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mid = 1
         
     | 
| 
      
 89 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.portalid = 2
         
     | 
| 
      
 90 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.key = "test_key"
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mid.should eql(1)
         
     | 
| 
      
 93 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.portalid.should eql(2)
         
     | 
| 
      
 94 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.key.should eql("test_key")
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                it 'should set by hash' do
         
     | 
| 
      
 98 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.config = {:mid => 1, :portalid => 2, :key => "test_key"}
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mid.should eql(1)
         
     | 
| 
      
 101 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.portalid.should eql(2)
         
     | 
| 
      
 102 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.key.should eql("test_key")
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                it 'should set by block' do
         
     | 
| 
      
 106 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.config do |c|
         
     | 
| 
      
 107 
     | 
    
         
            +
                    c.mid = 1
         
     | 
| 
      
 108 
     | 
    
         
            +
                    c.portalid = 2
         
     | 
| 
      
 109 
     | 
    
         
            +
                    c.key = "test_key"
         
     | 
| 
      
 110 
     | 
    
         
            +
                  end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.mid.should eql(1)
         
     | 
| 
      
 113 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.portalid.should eql(2)
         
     | 
| 
      
 114 
     | 
    
         
            +
                  ActivePayment::Payone::Gateway.key.should eql("test_key")
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                it 'should set by yml' do
         
     | 
| 
      
 118 
     | 
    
         
            +
                  File.open("#{FIXTURES_PATH}/activepayment_config.yml") do |config_file|
         
     | 
| 
      
 119 
     | 
    
         
            +
                    ActivePayment::Payone::Gateway.config = YAML.load(config_file.read)['development']
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                    ActivePayment::Payone::Gateway.mid.should eql(1)
         
     | 
| 
      
 122 
     | 
    
         
            +
                    ActivePayment::Payone::Gateway.portalid.should eql(2)
         
     | 
| 
      
 123 
     | 
    
         
            +
                    ActivePayment::Payone::Gateway.key.should eql("test_key")
         
     | 
| 
      
 124 
     | 
    
         
            +
                  end
         
     | 
| 
      
 125 
     | 
    
         
            +
                end
         
     | 
| 
      
 126 
     | 
    
         
            +
              end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe ActivePayment::Payone::Response do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              it "should get params by []" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                File.open("#{FIXTURES_PATH}/payone/gateway/successful_authorization_response.txt") do |file|
         
     | 
| 
      
 7 
     | 
    
         
            +
                  response = ActivePayment::Payone::Response.new(file.read)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  response[:status].should eql('APPROVED')
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it "should get params by method" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                File.open("#{FIXTURES_PATH}/payone/gateway/successful_authorization_response.txt") do |file|
         
     | 
| 
      
 14 
     | 
    
         
            +
                  response = ActivePayment::Payone::Response.new(file.read)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  response.status.should eql('APPROVED')
         
     | 
| 
      
 16 
     | 
    
         
            +
                  response.successful?.should be_true
         
     | 
| 
      
 17 
     | 
    
         
            +
                  response.failed?.should be_false
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe ActivePayment::Response do
         
     | 
| 
      
 3 
     | 
    
         
            +
            describe ActivePayment::Wirecard::Response do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              it "should parse response" do
         
     | 
| 
       6 
6 
     | 
    
         
             
                File.open("#{FIXTURES_PATH}/wirecard/gateway/successful_authorization_response.xml") do |file|
         
     | 
| 
       7 
     | 
    
         
            -
                  response = ActivePayment::Response.new(file)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  response = ActivePayment::Wirecard::Response.new(file)
         
     | 
| 
       8 
8 
     | 
    
         
             
                  response.job_id.should eql('test dummy data')
         
     | 
| 
       9 
9 
     | 
    
         
             
                  response['GuWID'].should eql('C822580121385121429927')
         
     | 
| 
       10 
10 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: activepayment
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,97 +9,9 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2011- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2011-08-30 00:00:00.000000000 +02:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
     | 
    
         
            -
            dependencies:
         
     | 
| 
       15 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
     | 
    
         
            -
              name: activesupport
         
     | 
| 
       17 
     | 
    
         
            -
              requirement: &6839600 !ruby/object:Gem::Requirement
         
     | 
| 
       18 
     | 
    
         
            -
                none: false
         
     | 
| 
       19 
     | 
    
         
            -
                requirements:
         
     | 
| 
       20 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       21 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       22 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       23 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       24 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       25 
     | 
    
         
            -
              version_requirements: *6839600
         
     | 
| 
       26 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       27 
     | 
    
         
            -
              name: nokogiri
         
     | 
| 
       28 
     | 
    
         
            -
              requirement: &6839180 !ruby/object:Gem::Requirement
         
     | 
| 
       29 
     | 
    
         
            -
                none: false
         
     | 
| 
       30 
     | 
    
         
            -
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       32 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       34 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       35 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       36 
     | 
    
         
            -
              version_requirements: *6839180
         
     | 
| 
       37 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       38 
     | 
    
         
            -
              name: builder
         
     | 
| 
       39 
     | 
    
         
            -
              requirement: &6838760 !ruby/object:Gem::Requirement
         
     | 
| 
       40 
     | 
    
         
            -
                none: false
         
     | 
| 
       41 
     | 
    
         
            -
                requirements:
         
     | 
| 
       42 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       43 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       44 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       45 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       46 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       47 
     | 
    
         
            -
              version_requirements: *6838760
         
     | 
| 
       48 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       49 
     | 
    
         
            -
              name: money
         
     | 
| 
       50 
     | 
    
         
            -
              requirement: &6838300 !ruby/object:Gem::Requirement
         
     | 
| 
       51 
     | 
    
         
            -
                none: false
         
     | 
| 
       52 
     | 
    
         
            -
                requirements:
         
     | 
| 
       53 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       54 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       55 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       56 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       57 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       58 
     | 
    
         
            -
              version_requirements: *6838300
         
     | 
| 
       59 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       60 
     | 
    
         
            -
              name: uuid
         
     | 
| 
       61 
     | 
    
         
            -
              requirement: &6837880 !ruby/object:Gem::Requirement
         
     | 
| 
       62 
     | 
    
         
            -
                none: false
         
     | 
| 
       63 
     | 
    
         
            -
                requirements:
         
     | 
| 
       64 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       65 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       66 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       67 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       68 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       69 
     | 
    
         
            -
              version_requirements: *6837880
         
     | 
| 
       70 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       71 
     | 
    
         
            -
              name: rake
         
     | 
| 
       72 
     | 
    
         
            -
              requirement: &6834880 !ruby/object:Gem::Requirement
         
     | 
| 
       73 
     | 
    
         
            -
                none: false
         
     | 
| 
       74 
     | 
    
         
            -
                requirements:
         
     | 
| 
       75 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       76 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       77 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       78 
     | 
    
         
            -
              type: :development
         
     | 
| 
       79 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       80 
     | 
    
         
            -
              version_requirements: *6834880
         
     | 
| 
       81 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       82 
     | 
    
         
            -
              name: rspec
         
     | 
| 
       83 
     | 
    
         
            -
              requirement: &6834460 !ruby/object:Gem::Requirement
         
     | 
| 
       84 
     | 
    
         
            -
                none: false
         
     | 
| 
       85 
     | 
    
         
            -
                requirements:
         
     | 
| 
       86 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       87 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       88 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       89 
     | 
    
         
            -
              type: :development
         
     | 
| 
       90 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       91 
     | 
    
         
            -
              version_requirements: *6834460
         
     | 
| 
       92 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       93 
     | 
    
         
            -
              name: forgery
         
     | 
| 
       94 
     | 
    
         
            -
              requirement: &6834040 !ruby/object:Gem::Requirement
         
     | 
| 
       95 
     | 
    
         
            -
                none: false
         
     | 
| 
       96 
     | 
    
         
            -
                requirements:
         
     | 
| 
       97 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       98 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       99 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       100 
     | 
    
         
            -
              type: :development
         
     | 
| 
       101 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       102 
     | 
    
         
            -
              version_requirements: *6834040
         
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
       103 
15 
     | 
    
         
             
            description: ActivePayment is an abstraction layer for different Payment-Interfaces
         
     | 
| 
       104 
16 
     | 
    
         
             
              (XML, JSON)
         
     | 
| 
       105 
17 
     | 
    
         
             
            email:
         
     | 
| 
         @@ -116,11 +28,16 @@ files: 
     | 
|
| 
       116 
28 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       117 
29 
     | 
    
         
             
            - activepayment.gemspec
         
     | 
| 
       118 
30 
     | 
    
         
             
            - lib/activepayment.rb
         
     | 
| 
      
 31 
     | 
    
         
            +
            - lib/activepayment/gateway_base.rb
         
     | 
| 
      
 32 
     | 
    
         
            +
            - lib/activepayment/payone/gateway.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
            - lib/activepayment/payone/response.rb
         
     | 
| 
       119 
34 
     | 
    
         
             
            - lib/activepayment/railtie.rb
         
     | 
| 
       120 
     | 
    
         
            -
            - lib/activepayment/response.rb
         
     | 
| 
       121 
35 
     | 
    
         
             
            - lib/activepayment/version.rb
         
     | 
| 
       122 
36 
     | 
    
         
             
            - lib/activepayment/wirecard/gateway.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/activepayment/wirecard/response.rb
         
     | 
| 
       123 
38 
     | 
    
         
             
            - spec/fixtures/activepayment_config.yml
         
     | 
| 
      
 39 
     | 
    
         
            +
            - spec/fixtures/payone/gateway/authorization_request.txt
         
     | 
| 
      
 40 
     | 
    
         
            +
            - spec/fixtures/payone/gateway/successful_authorization_response.txt
         
     | 
| 
       124 
41 
     | 
    
         
             
            - spec/fixtures/wirecard/gateway/authorization_request.xml
         
     | 
| 
       125 
42 
     | 
    
         
             
            - spec/fixtures/wirecard/gateway/authorization_request_with_address.xml
         
     | 
| 
       126 
43 
     | 
    
         
             
            - spec/fixtures/wirecard/gateway/capture_authorization_request.xml
         
     | 
| 
         @@ -129,10 +46,14 @@ files: 
     | 
|
| 
       129 
46 
     | 
    
         
             
            - spec/fixtures/wirecard/gateway/purchase_request_with_3d.xml
         
     | 
| 
       130 
47 
     | 
    
         
             
            - spec/fixtures/wirecard/gateway/successful_authorization_response.xml
         
     | 
| 
       131 
48 
     | 
    
         
             
            - spec/fixtures/wirecard/gateway/successful_capture_response.xml
         
     | 
| 
      
 49 
     | 
    
         
            +
            - spec/functional/payone_spec.rb
         
     | 
| 
       132 
50 
     | 
    
         
             
            - spec/functional/wirecard_spec.rb
         
     | 
| 
       133 
51 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       134 
     | 
    
         
            -
            - spec/unit/ 
     | 
| 
      
 52 
     | 
    
         
            +
            - spec/unit/gateway_base_spec.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - spec/unit/payone/gateway_spec.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - spec/unit/payone/response_spec.rb
         
     | 
| 
       135 
55 
     | 
    
         
             
            - spec/unit/wirecard/gateway_spec.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - spec/unit/wirecard/response_spec.rb
         
     | 
| 
       136 
57 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       137 
58 
     | 
    
         
             
            homepage: ''
         
     | 
| 
       138 
59 
     | 
    
         
             
            licenses: []
         
     | 
| 
         @@ -1,58 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module ActivePayment
         
     | 
| 
       2 
     | 
    
         
            -
              class Response
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
                def initialize(xml)
         
     | 
| 
       5 
     | 
    
         
            -
                  @doc = Nokogiri::XML(xml)
         
     | 
| 
       6 
     | 
    
         
            -
                  if @doc.at_css('WIRECARD_BXML').nil?
         
     | 
| 
       7 
     | 
    
         
            -
                    raise ActivePayment::Exception, "No valid response"
         
     | 
| 
       8 
     | 
    
         
            -
                  end
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                def to_s
         
     | 
| 
       12 
     | 
    
         
            -
                  @doc.to_s
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                def ok?
         
     | 
| 
       16 
     | 
    
         
            -
                  return_code.to_i.eql?(0)
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                def [](node_name)
         
     | 
| 
       20 
     | 
    
         
            -
                  parse(@doc.at_css(node_name).content)
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                def successful?
         
     | 
| 
       24 
     | 
    
         
            -
                  self.function_result.eql?('ACK') || self.function_result.eql?('PENDING')
         
     | 
| 
       25 
     | 
    
         
            -
                end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                def failed?
         
     | 
| 
       28 
     | 
    
         
            -
                  self.function_result.eql?('NOK')
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                public
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                def method_missing(method, *args)
         
     | 
| 
       34 
     | 
    
         
            -
                  node_name = method.to_node_name
         
     | 
| 
       35 
     | 
    
         
            -
                  unless node_name.blank?
         
     | 
| 
       36 
     | 
    
         
            -
                    node = @doc.at_css(node_name)
         
     | 
| 
       37 
     | 
    
         
            -
                    unless node.nil?
         
     | 
| 
       38 
     | 
    
         
            -
                      parse(@doc.at_css(node_name).content)
         
     | 
| 
       39 
     | 
    
         
            -
                    else
         
     | 
| 
       40 
     | 
    
         
            -
                      super
         
     | 
| 
       41 
     | 
    
         
            -
                    end
         
     | 
| 
       42 
     | 
    
         
            -
                  else
         
     | 
| 
       43 
     | 
    
         
            -
                    super
         
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                private
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                def parse(value)
         
     | 
| 
       50 
     | 
    
         
            -
                  begin
         
     | 
| 
       51 
     | 
    
         
            -
                    return Integer(value)
         
     | 
| 
       52 
     | 
    
         
            -
                  rescue
         
     | 
| 
       53 
     | 
    
         
            -
                    return value
         
     | 
| 
       54 
     | 
    
         
            -
                  end
         
     | 
| 
       55 
     | 
    
         
            -
                end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
            end
         
     |