Sha256: 517083fa55cf143be98787f8142e70c1b0293c6f8146707939f35163f4148651

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

# Ogone Integration developed by Openminds (www.openminds.be)
# For problems contact us at ogone@openminds.be
require 'active_merchant'
require 'active_merchant_ogone/helper.rb'
require 'active_merchant_ogone/notification.rb'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Ogone
        
        mattr_accessor :inbound_signature
        mattr_accessor :outbound_signature
        
        mattr_accessor :test_service_url
        mattr_accessor :live_service_url
        
        self.test_service_url = 'https://secure.ogone.com/ncol/test/orderstandard.asp'
        self.live_service_url = 'https://secure.ogone.com/ncol/prod/orderstandard.asp'
        
        def self.setup
          yield(self)
        end
        
        def self.service_url
          mode = ActiveMerchant::Billing::Base.integration_mode
          case mode
          when :production then self.live_service_url
          when :test       then self.test_service_url
          else
            raise StandardError, "Integration mode set to an invalid value: #{mode}"
          end
        end
        
        def self.notification(post, options={})
          Notification.new(post, options={})
        end
        
        def self.outbound_message_signature(fields, signature=nil)
          signature ||= self.outbound_signature
          keys = %w( orderID amount currency PSPID )
          datastring = keys.collect{|key| fields[key]}.join('')
          Digest::SHA1.hexdigest("#{datastring}#{signature}").upcase
        end
        
        def self.inbound_message_signature(fields, signature=nil)
          signature ||= self.inbound_signature
          keys = %w( orderID currency amount PM ACCEPTANCE STATUS CARDNO PAYID NCERROR BRAND )
          datastring = keys.collect{|key| fields[key]}.join('')
          Digest::SHA1.hexdigest("#{datastring}#{signature}").upcase
        end
      end
    end
  end

  class OgoneError < ActiveMerchantError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_merchant_ogone-0.1.2 lib/active_merchant_ogone.rb