Class: Minfraud::FraudReportAssessment
- Inherits:
-
Object
- Object
- Minfraud::FraudReportAssessment
- Defined in:
- app/services/minfraud/fraud_report_assessment.rb
Overview
Builds a minFraud Insights request for an order/payment, calls the Insights
API via InsightsClient, and maps the response onto the given FraudReport.
Extracted from Order::FraudDetector so that service stays focused on fraud
orchestration and decisioning, and so the request/response mapping lives
alongside the client it talks to. Request keys and response fields match the
MaxMind schema (the same data the minfraud gem sent and parsed).
Constant Summary collapse
- PAYMENT_METHOD_MAP =
Maps a Heatwave Payment category to a minFraud
payment.methodvalue. { Payment::CREDIT_CARD => 'card', Payment::CREDIT_CARD_TERMINAL => 'card', Payment::PAYPAL => 'digital_wallet', Payment::PAYPAL_INVOICE => 'digital_wallet', Payment::ECHECK => 'bank_debit', Payment::CHECK => 'bank_debit', Payment::WIRE => 'bank_transfer', Payment::AMAZON_PAY => 'digital_wallet' }.freeze
- AVS_CODES =
AVS result code, keyed by [card is US?, address_line1_check,
address_zip_check]. Theunavailablecases are handled separately. { [true, 'pass', 'pass'] => 'Y', # US: street + 5-digit zip match [true, 'pass', 'fail'] => 'A', # US: street matches, zip does not [true, 'fail', 'pass'] => 'Z', # US: zip matches, street does not [true, 'fail', 'fail'] => 'N', # US: neither matches [false, 'pass', 'pass'] => 'M', # non-US: street + postal match [false, 'pass', 'fail'] => 'B', # non-US: street matches, postal not verified [false, 'fail', 'pass'] => 'P', # non-US: postal matches, street not verified [false, 'fail', 'fail'] => 'C' # non-US: neither matches }.freeze
Instance Method Summary collapse
-
#assess! ⇒ void
Run the assessment, mutating the FraudReport in place.
-
#initialize(order, payment, fraud_report, is_pickup:) ⇒ FraudReportAssessment
constructor
A new instance of FraudReportAssessment.
Constructor Details
#initialize(order, payment, fraud_report, is_pickup:) ⇒ FraudReportAssessment
Returns a new instance of FraudReportAssessment.
44 45 46 47 48 49 |
# File 'app/services/minfraud/fraud_report_assessment.rb', line 44 def initialize(order, payment, fraud_report, is_pickup:) @order = order @payment = payment @fr = fraud_report @is_pickup = is_pickup end |
Instance Method Details
#assess! ⇒ void
This method returns an undefined value.
Run the assessment, mutating the FraudReport in place. Network / parse
failures are non-fatal: they record fraud_report.minfraud_error and
report the exception, leaving the rest of the report intact.
56 57 58 59 60 61 |
# File 'app/services/minfraud/fraud_report_assessment.rb', line 56 def assess! store_insights(client.insights(request)) rescue StandardError => e @fr.minfraud_error = e. ErrorReporting.error e end |