Sha256: 7f617eef2cfa08080ed72495e6e34b3736bec3705097c263d031fd778827027a

Contents?: true

Size: 1.61 KB

Versions: 40

Compression:

Stored size: 1.61 KB

Contents

require 'net/http'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Verkkomaksut
        class Notification < ActiveMerchant::Billing::Integrations::Notification

          # Is the payment complete or not. Verkkomaksut only has two statuses: random string or 0000000000 which means pending
          def complete?
            params['PAID'] != "0000000000"
          end 
          
          # Order id
          def order_id
            params['ORDER_NUMBER']
          end
          
          # Payment method used
          def method
            params['METHOD']
          end
          
          # When was this payment received by the client. 
          def received_at
            params['TIMESTAMP']
          end
          
          # Security key got from Verkkomaksut
          def security_key
            params['RETURN_AUTHCODE']
          end
          
          # Another way of asking the payment status
          def status
            if complete?
              "PAID"
            else
              "PENDING"
            end
          end
          
          # Acknowldges the payment. If the authcodes match, returns true.
          def acknowledge(authcode)
            return_authcode = [params["ORDER_NUMBER"], params["TIMESTAMP"], params["PAID"], params["METHOD"], authcode].join("|")
            Digest::MD5.hexdigest(return_authcode).upcase == params["RETURN_AUTHCODE"]
          end
 private
 
          def parse(post)
            post.each do |key, value|
              params[key] = value
            end
          end
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 5 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.38.1 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.38.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.37.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.36.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.35.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.35.1 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.34.1 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.34.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.33.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.32.1 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.32.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.31.1 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.31.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb