Sha256: bdf23e76a5f9fdad7bc3b922f669ffc660f855f86f362ec1ebe3f2fa8ed426f4

Contents?: true

Size: 1.86 KB

Versions: 75

Compression:

Stored size: 1.86 KB

Contents

require 'net/http'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module DirecPay
        class Notification < ActiveMerchant::Billing::Integrations::Notification
          RESPONSE_PARAMS = ['DirecPay Reference ID', 'Flag', 'Country', 'Currency', 'Other Details', 'Merchant Order No', 'Amount']
          
          def acknowledge
            true
          end

          def complete?
            status == 'Completed' || status == 'Pending'
          end

          def status
            case params['Flag']
            when 'SUCCESS'
              'Completed'
            when 'PENDING'
              'Pending'
            when 'FAIL'
              'Failed'
            else
              'Error'
            end
          end

          def item_id
            params['Merchant Order No']
          end
          
          def transaction_id
            params['DirecPay Reference ID']
          end
          
          # the money amount we received in X.2 decimal
          def gross
            params['Amount']
          end
          
          def currency
            params['Currency']
          end
          
          def country
            params['Country']
          end
          
          def other_details
            params['Other Details']
          end

          def test?
            false
          end

          # Take the posted data and move the relevant data into a hash
          def parse(post)
            super
            
            values = params['responseparams'].to_s.split('|')
            response_params = values.size == 3 ? ['DirecPay Reference ID', 'Flag', 'Error message'] : RESPONSE_PARAMS
            response_params.each_with_index do |name, index|
              params[name] = values[index]
            end
            params
          end
          
        end
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 13 rubygems

Version Path
activemerchant-1.30.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
jelaniharris-activemerchant-1.29.2 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.29.3 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.29.2 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.29.1 lib/active_merchant/billing/integrations/direc_pay/notification.rb
jelaniharris-activemerchant-1.29.1 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.29.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-nsp-1.27.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.28.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
yetanothernguyen-activemerchant-1.21.2 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.27.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
yetanothernguyen-activemerchant-1.21.1 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.26.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.25.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
jelaniharris-activemerchant-1.24.1 lib/active_merchant/billing/integrations/direc_pay/notification.rb
activemerchant-1.24.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb
tlconnor-activemerchant-1.23.3 lib/active_merchant/billing/integrations/direc_pay/notification.rb
tlconnor-activemerchant-1.23.2 lib/active_merchant/billing/integrations/direc_pay/notification.rb
tlconnor-activemerchant-1.23.1 lib/active_merchant/billing/integrations/direc_pay/notification.rb
tlconnor-activemerchant-1.23.0 lib/active_merchant/billing/integrations/direc_pay/notification.rb