Sha256: ab85c916bce3193b4262ed75368ff83d5272d4ddec2d7724ded11ca5b425042f

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module PayuIn
        class Return < ActiveMerchant::Billing::Integrations::Return

          def initialize(query_string, options = {})
            super
            @notification = Notification.new(query_string, options)
          end

          # PayU Transaction Id
          #
          def transaction_id
            @notification.transaction_id
          end

          # Returns the status of the transaction as a string
          # The status can be one of the following
          #
          # invalid - transaction id not present
          # tampered - checksum does not mismatch
          # mismatch - order id mismatch
          # success - transaction success
          # pending - transaction pending
          # failure - transaction failure
          #
          # payu does not put the discount field in the checksum
          # it can be easily forged by the attacker without detection
          #
          def status( order_id, order_amount )
            if @notification.invoice_ok?( order_id ) && @notification.amount_ok?( BigDecimal.new(order_amount) )
              @notification.status
            else
              'mismatch'
            end
          end

          # check success of the transaction
          # check order_id and
          def success?
            status( @params['txnid'], @params['amount'] ) == 'success'
          end

          def message
            @notification.message
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activemerchant-1.36.0 lib/active_merchant/billing/integrations/payu_in/return.rb
activemerchant-1.35.0 lib/active_merchant/billing/integrations/payu_in/return.rb
activemerchant-1.35.1 lib/active_merchant/billing/integrations/payu_in/return.rb
activemerchant-1.34.1 lib/active_merchant/billing/integrations/payu_in/return.rb
activemerchant-1.34.0 lib/active_merchant/billing/integrations/payu_in/return.rb
activemerchant-1.33.0 lib/active_merchant/billing/integrations/payu_in/return.rb