Sha256: c3082a1b0deb732844f6701c0c6d0d5f2644258db5aaed05771bfd0cbe0ea573

Contents?: true

Size: 1.68 KB

Versions: 39

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

39 entries across 39 versions & 2 rubygems

Version Path
activemerchant-1.85.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.84.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.83.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.82.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.81.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.80.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.79.2 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.79.1 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.79.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.78.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.77.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.76.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.75.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.74.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.73.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.72.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.71.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.70.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.69.0 lib/active_merchant/billing/gateways/beanstream_interac.rb
activemerchant-1.68.0 lib/active_merchant/billing/gateways/beanstream_interac.rb