Skip to content

yamimaio/yams-fraud-detector

Repository files navigation

README

Yam's Fraud Detector

System Requirements

  • Web server with URL rewriting
  • PHP 7.3 or newer

Setup Without Docker

  1. cd to project root
  2. git clone https://github.com/yamimaio/yams-fraud-detector.git .
  3. Navigate into your project’s root directory and execute the bash command composer install.
  4. Setup your localhost, Apache or Nginx to serve /app

Setup With Docker

  1. cd to project root
  2. git clone https://github.com/yamimaio/yams-fraud-detector.git .
  3. Navigate into your project’s root directory and execute the bash command docker-compose up.
  4. You're ready to go on http://localhost:8088
  5. Import postman collection available in docs for quick startup using the API

Tests

Run tests with docker-compose run api php /app/vendor/phpunit/phpunit/phpunit -c /app/tests

Available Routes

Only routes accesible are:

fraud/status

Indicates if the given order is a fraud or not. Response:

{
    "status": false
}

Method: POST Content-type: application/json Payload: Order information (see Order definition) Check it out on Heroku: https://warm-plateau-67794.herokuapp.com/fraud/status

fraud/scoring

Returns the fraud scoring for the given order. Response:

{
    "scoring": 70
}

Method: POST Content-type: application/json Payload: Order information (see Order definition) Check it out on Heroku: https://warm-plateau-67794.herokuapp.com/fraud/scoring

Order Definition

{
  "transaction": {
    "order_id": "1234-A",
    "ordered_on": "2017-02-13 21:27:45",
    "order_total": 122.23,
    "order_currency": "USD",
    "user_id": "22",
    "user_first_name": "Yamila",
    "user_last_name": "Maio"
  },
  "billing": {
    "first_name": "John",
    "last_name": "Smith",
    "address1": "123 Main Street",
    "company": "Acme Inc",
    "city": "New York City",
    "region": "NY",
    "postal_code": "10001",
    "country": "US",
    "email": "email@acme.com",
    "phone": "212-289-1293"
  },
  "payment": {
    "method": "credit_card",
    "type": "mc",
    "cc_holder": "Yamila Maio",
    "cc_number": "56657577655559999",
    "exp_date": "0221",
    "payment_status": "paid"
  },
  "travel_ticket": {
    "trip_currency": "USD",
    "method": "plane",
    "from_code": "LAXTUF2",
    "from_name": "5201 E Olympic Blvd E",
    "from_city": "Los Angeles",
    "from_country": "USA",
    "depart_on": "2017-05-15 10:00:00",
    "to_code": "LASTUF",
    "to_name": "99 S Martin L King Blvd",
    "return_on:": "2017-05-15 15:05:00",
    "to_city": "Las Vegas",
    "to_country": "USA",
    "trip_type": "one-way",
    "passengers": 1
  },
  "travel_passengers": [
    {
      "first_name": "John",
      "last_name": "Smith"
    }
  ]
}

Fraud Detector Configuration

Fraud Detector and scoring system can be configured in app/config/config.json file.

Options

  • fraudScoring: Int. Scoring which will define an order is fraud. Default: 80.
  • maxScoring: Int. Maximum possible scoring. Default: 100.
  • rules: Rules for risk scoring. Array of objects. Each object MUST have at least a name property with name of the rule. If no rule should be applied, set as an empty array. See available list of Rule names.
  • maxScoringRules: Rules that if broken, define immediate fraud. Array of objects. Each object MUST have at least a name property with name of the rule. If no rule should be applied, set as an empty array. See available list of Rule names.

Rules

The following rules are available (for either standard or max scoring rule. You may use them as you wish).

For each rule you choose as standard you may indicate the property "scoring" which will set the scoring level this rule adds if broken. If scoring is not set it defaults to 10.

For each rule you choose as maxScoringRule the scoring level will be automatically set to whatever you have configured as maxScoring.

  • CCHolderLastName: Credit Card Holder last name is not found in passengers last names.
  • DepartureTimeFrame: Date/Time of order is less than a given interval away from Date/Time of departure. For this rule you must add the property "timeFrame" (in seconds). TimeFrame will be the minimum interval of time from order request to departure that is acceptable as not risky.
  • PaxLastName: None of the passengers share last name.
  • RiskyCountry: Destination country is marked as risky. This can happen under 2 circumstances. a) the country is marked as risky b) the country limits with the departure country. If both cases are met (limit country is also risky), scoring assigned is doubled.
  • BlacklistedCard: Credit Card it blacklisted as stolen. This rule defaults to a maxScoringRule.

Try it out

If you wish to test rules you can use:

  • Blacklisted credit card: 5665777755559999
  • Risky Countries: Iran, Irak or Palestine
  • Neighbor Countries: Brasil, Paraguay or Palestine

About

Fraud Detector Api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors