Sha256: 8545f1980a5ae730d31bb83962add6489b99ba74109f28976de83f704000fabd

Contents?: true

Size: 1.73 KB

Versions: 26

Compression:

Stored size: 1.73 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
        ('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_markdown
    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

26 entries across 26 versions & 2 rubygems

Version Path
activemerchant-1.108.0 lib/support/gateway_support.rb
activemerchant-1.107.4 lib/support/gateway_support.rb
activemerchant-1.107.3 lib/support/gateway_support.rb
activemerchant-1.107.2 lib/support/gateway_support.rb
activemerchant-1.107.1 lib/support/gateway_support.rb
activemerchant-1.106.0 lib/support/gateway_support.rb
activemerchant-1.105.0 lib/support/gateway_support.rb
activemerchant-1.104.0 lib/support/gateway_support.rb
activemerchant-1.103.0 lib/support/gateway_support.rb
activemerchant-1.102.0 lib/support/gateway_support.rb
activemerchant-1.101.0 lib/support/gateway_support.rb
activemerchant-1.100.0 lib/support/gateway_support.rb
activemerchant-1.99.0 lib/support/gateway_support.rb
activemerchant-1.98.0 lib/support/gateway_support.rb
active_accountability_merchant-1.97.1 lib/support/gateway_support.rb
activemerchant-1.97.0 lib/support/gateway_support.rb
activemerchant-1.96.0 lib/support/gateway_support.rb
activemerchant-1.95.0 lib/support/gateway_support.rb
activemerchant-1.94.0 lib/support/gateway_support.rb
activemerchant-1.93.0 lib/support/gateway_support.rb