Sha256: 74657ea480ec530a14b31c2b24e491810c35152f29d80991c06fcb2f015c5b78

Contents?: true

Size: 1.62 KB

Versions: 10

Compression:

Stored size: 1.62 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
          
          # Acknowledges the payment. If the authcodes match, returns true.
          def acknowledge(authcode = nil)
            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

10 entries across 10 versions & 1 rubygems

Version Path
activemerchant-1.43.3 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.43.1 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.43.0 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.42.9 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.42.8 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.42.7 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.42.6 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.42.5 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.42.4 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb
activemerchant-1.42.3 lib/active_merchant/billing/integrations/verkkomaksut/notification.rb