Sha256: 9dd44844f4430a95ce4b60085a685cd3d330c40ce241510215cb4e9ff8736360

Contents?: true

Size: 1.64 KB

Versions: 30

Compression:

Stored size: 1.64 KB

Contents

require 'rubygems'
require 'active_support'
require 'active_merchant'


class GatewaySupport #:nodoc:
  ACTIONS = [:purchase, :authorize, :capture, :void, :credit, :recurring]
  
  include ActiveMerchant::Billing

  attr_reader :gateways
  
  def initialize
    Dir[File.expand_path(File.dirname(__FILE__) + '/../active_merchant/billing/gateways/*.rb')].each do |f|
      filename = File.basename(f, '.rb') 
      gateway_name = filename + '_gateway'
      begin
        gateway_class = ('ActiveMerchant::Billing::' + gateway_name.camelize).constantize
      rescue NameError
        puts "Could not load gateway " + gateway_name.camelize + " from " + f + "."
      end
    end
    @gateways = Gateway.implementations.sort_by(&:name)
    @gateways.delete(ActiveMerchant::Billing::BogusGateway)
  end
  
  def each_gateway
    @gateways.each{|g| yield g }
  end
  
  def features
    width = 15
    
    print "Name".center(width + 20)
    ACTIONS.each{|f| print "#{f.to_s.capitalize.center(width)}" }
    puts
    
    each_gateway do |g|
      print "#{g.display_name.ljust(width + 20)}"
      ACTIONS.each do |f|
        print "#{(g.instance_methods.include?(f.to_s) ? "Y" : "N").center(width)}"
      end
      puts
    end
  end
  
  def to_rdoc
    each_gateway do |g|
      puts "* {#{g.display_name}}[#{g.homepage_url}] - #{g.supported_countries.join(', ')}"
    end
  end
  
  def to_textile
    each_gateway do |g|
      puts %/ * "#{g.display_name}":#{g.homepage_url} [#{g.supported_countries.join(', ')}]/
    end
  end
  
  def to_s
    each_gateway do |g|
      puts "#{g.display_name} - #{g.homepage_url} [#{g.supported_countries.join(', ')}]"
    end
  end
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/support/gateway_support.rb
tanga_activemerchant-1.38.0.4 lib/support/gateway_support.rb
tanga_activemerchant-1.38.0.3 lib/support/gateway_support.rb
tanga_activemerchant-1.38.0.2 lib/support/gateway_support.rb
tanga_activemerchant-1.38.0.1 lib/support/gateway_support.rb
tanga_activemerchant-1.38.0 lib/support/gateway_support.rb
tanga_activemerchant-1.37.0 lib/support/gateway_support.rb
activemerchant-1.38.1 lib/support/gateway_support.rb
activemerchant-1.38.0 lib/support/gateway_support.rb
activemerchant-1.37.0 lib/support/gateway_support.rb
activemerchant-1.36.0 lib/support/gateway_support.rb
activemerchant-1.35.0 lib/support/gateway_support.rb
activemerchant-1.35.1 lib/support/gateway_support.rb
activemerchant-1.34.1 lib/support/gateway_support.rb
activemerchant-1.34.0 lib/support/gateway_support.rb
activemerchant-1.33.0 lib/support/gateway_support.rb
activemerchant-1.32.1 lib/support/gateway_support.rb
activemerchant-1.32.0 lib/support/gateway_support.rb
activemerchant-1.31.1 lib/support/gateway_support.rb
activemerchant-1.31.0 lib/support/gateway_support.rb