Sha256: 071806377245e52699fa778d75f25470e2ca76523f155669159850ae08d46e5a

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

require 'net/http'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Paydollar

        class Notification < ActiveMerchant::Billing::Integrations::Notification

          def complete?
            status == 'Completed'
          end

          def item_id
            @params['Ref']
          end

          def currency
            CURRENCY_MAP.key(@params['Cur'])
          end

          def gross
            @params['Amt']
          end

          def transaction_id
            @params['PayRef']
          end

          def status
            case @params['successcode']
              when '0' then 'Completed'
              else 'Failed'
            end
          end

          def acknowledge(authcode = nil)
            # paydollar supports multiple signature keys, therefore we need to check if any
            # of their signatures match ours
            hash = @params['secureHash']
            if !hash
              return false
            end
            hash.split(',').include? generate_secure_hash
          end

          private
          def generate_secure_hash
            fields = [@params['src'],
                      @params['prc'],
                      @params['successcode'],
                      @params['Ref'],
                      @params['PayRef'],
                      @params['Cur'],
                      @params['Amt'],
                      @params['payerAuth']]
            Paydollar.sign(fields, @options[:credential2])
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activemerchant-1.43.3 lib/active_merchant/billing/integrations/paydollar/notification.rb
activemerchant-1.43.1 lib/active_merchant/billing/integrations/paydollar/notification.rb
activemerchant-1.43.0 lib/active_merchant/billing/integrations/paydollar/notification.rb
activemerchant-1.42.9 lib/active_merchant/billing/integrations/paydollar/notification.rb
activemerchant-1.42.8 lib/active_merchant/billing/integrations/paydollar/notification.rb
activemerchant-1.42.7 lib/active_merchant/billing/integrations/paydollar/notification.rb