Sha256: 088cadeb676167bcdb6fc0dcc8d5bdd53c96eb54c318af20e2ff15c496c8ec40

Contents?: true

Size: 1.68 KB

Versions: 42

Compression:

Stored size: 1.68 KB

Contents

require 'active_merchant/billing/gateways/beanstream/beanstream_core'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class BeanstreamInteracResponse < Response
      def redirect
        params['pageContents']
      end
    end

    class BeanstreamInteracGateway < Gateway
      include BeanstreamCore

      # Confirm a transaction posted back from the bank to Beanstream.
      # Confirming a transaction does not require any credentials,
      # and in an application with many merchants sharing a funded
      # URL the application may not yet know which merchant the
      # post back is for until the response of the confirmation is
      # received, which contains the order number.
      def self.confirm(transaction)
        gateway = new(login: '')
        gateway.confirm(transaction)
      end

      def purchase(money, options = {})
        post = {}
        add_amount(post, money)
        add_invoice(post, options)
        add_address(post, options)
        add_interac_details(post, options)
        add_transaction_type(post, :purchase)
        commit(post)
      end

      def success?(response)
        response[:responseType] == 'R' || response[:trnApproved] == '1' || response[:responseCode] == '1'
      end

      # Confirm a transaction posted back from the bank to Beanstream.
      def confirm(transaction)
        post(transaction)
      end

      private

      def add_interac_details(post, options)
        address = options[:billing_address] || options[:address] || {}
        post[:trnCardOwner] = address[:name]
        post[:paymentMethod] = 'IO'
      end

      def build_response(*args)
        BeanstreamInteracResponse.new(*args)
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 4 rubygems

Version Path
swiss-crm-activemerchant-1.0.15 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-crm-activemerchant-1.0.14 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-crm-activemerchant-1.0.13 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-crm-activemerchant-1.0.12 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.11 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.10 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.9 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.8 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.7 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.6 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.5 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.4 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.137.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.2 lib/active_merchant/billing/gateways/beanstream_interac.rb
swiss-activemerchant-1.0.1 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.133.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.131.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.130.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.129.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.126.0 lib/active_merchant/billing/gateways/beanstream_interac.rb