Sha256: 376fd98134a00eced536598dc981681f5d60eb37ef4b3789896f72510483d67f

Contents?: true

Size: 1.19 KB

Versions: 28

Compression:

Stored size: 1.19 KB

Contents

module Workarea
  class Checkout
    module Fraud
      class Analyzer
        attr_reader :checkout

        delegate :order, :user, :payment, :payment_profile, :shipping, :shippings,
            to: :checkout, allow_nil: true
        delegate :fraud_suspected?, to: :order

        def initialize(checkout)
          @checkout = checkout
        end

        def decide!
          begin
            decision = make_decision.tap { |r| r.analyzer = self.class.name }
          rescue => e
            decision = error_decision(e.message)
          ensure
            order.set_fraud_decision!(decision)
          end
        end

        # Gets a decision about the fraudlence of a given checkout
        #
        # @param [Workarea::Checkout] checkout
        #
        # @return [Workarea::Order::FraudDecision]
        #
        def make_decision(checkout = nil)
          raise(NotImplementedError, "#{self.class} must implement the #make_decision method")
        end

        def error_decision(message)
          Workarea::Order::FraudDecision.new(
            decision: :no_decision,
            message: "An error occured during the fraud check: #{message}"
          )
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.26 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.25 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.23 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.22 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.21 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.20 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.19 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.18 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.17 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.16 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.15 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.14 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.13 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.12 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.11 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.10 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.9 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.8 app/models/workarea/checkout/fraud/analyzer.rb
workarea-core-3.5.7 app/models/workarea/checkout/fraud/analyzer.rb