Sha256: 93ee97e056218cc466443d30b9ebbba97ebe1cf596419cb6a03cfbb66555ede6
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
require 'active_merchant' module Skr module MerchantGateway class InvalidCard < StandardError end def self.get @gateway || _create_gateway end def self._create_gateway unless Lanes.env.production? return ActiveMerchant::Billing::BogusGateway.new end settings = Lanes::SystemSettings.for_ext('skr-ccgateway')['credit_card_gateway'] || {} gateway = nil if settings['type'] gateway = ActiveMerchant::Billing.const_get(settings['type'].classify) end if gw.nil? Lanes.logger.warn("Unable to find gateway class for id #{settings['type']}") raise ActiveRecord::RecordNotFound end gateway.new(settings.except('type')) end def purchase(amount, card) raise InvalidCard.new(credit_card.validate) unless credit_card.validate.empty? gw.purchase(amount, card) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stockor-0.5.0 | lib/skr/merchant_gateway.rb |
stockor-0.4.0 | lib/skr/merchant_gateway.rb |