Sha256: 557d30ad980e5ed39e84d502b20ec76c6737fdd41e37d72596dff33da3a115eb

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

require_relative 'errors'

module Jackpot

  class Factory

    def initialize(gateway_configuration)
      @gateway_configuration = HashWithIndifferentAccess.new gateway_configuration
    end 

    def build
      if @gateway_configuration[:type] == :braintree
        Jackpot::Gateway.new(ActiveMerchant::Billing::BraintreeGateway.new(
          :login =>    @gateway_configuration['login'], 
          :password => @gateway_configuration['password'], 
          :mode =>     @gateway_configuration['mode'])) 
      elsif @gateway_configuration['type'] == :bogus
         Jackpot::Gateway.new(ActiveMerchant::Billing::BogusGateway.new) 
      else 
        raise Jackpot::Errors::InvalidGateway.new "There is no #{@gateway_configuration['type']}: available options are :braintree, :bogus"
      end 

    end 

  end 
end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jackpot-0.0.3 lib/jackpot/factory.rb