Sha256: 231ba499d996754386914f49fbe1553e3a5d2ea65373ae24f83e5d360e833ce9

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 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 matches ours
            @params['secureHash'].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

1 entries across 1 versions & 1 rubygems

Version Path
activemerchant-1.42.6 lib/active_merchant/billing/integrations/paydollar/notification.rb