minFraud PHP API v3.2.0-beta.2

MinFraud extends ServiceClient
in package

This class provides a client API for accessing MaxMind minFraud Score, Insights and Factors.

Usage

The constructor takes your MaxMind account ID and license key. The object returned is immutable. To build up a request, call the ->with*() methods. Each of these returns a new object (a clone of the original) with the additional data. These can be chained together:

$client = new MinFraud(6, 'LICENSE_KEY');

$score = $client->withDevice(['ip_address'  => '1.1.1.1',
                              'session_age' => 3600.5,
                              'session_id'  => 'foobar',
                              'accept_language' => 'en-US'])
                ->withEmail(['domain' => 'maxmind.com'])
                ->score();

If the request fails, an exception is thrown.

Table of Contents

Constants

VERSION  = 'v3.2.0-beta.2'

Methods

__construct()  : mixed
factors()  : Factors
This method performs a minFraud Factors lookup using the request data in the current object and returns a model object for minFraud Factors.
insights()  : Insights
This method performs a minFraud Insights lookup using the request data in the current object and returns a model object for minFraud Insights.
score()  : Score
This method performs a minFraud Score lookup using the request data in the current object and returns a model object for minFraud Score.
with()  : MinFraud
This returns a `MinFraud` object with the array to be sent to the web service set to `$values`. Existing values will be replaced.
withAccount()  : MinFraud
This returns a `MinFraud` object with the `account` array set to the values provided. Existing `` data will be replaced.
withBilling()  : MinFraud
This returns a `MinFraud` object with the `billing` array set to `$values`. Existing `billing` data will be replaced.
withCreditCard()  : MinFraud
This returns a `MinFraud` object with the `credit_card` array set to provided values. Existing `credit_card` data will be replaced.
withCustomInputs()  : MinFraud
This returns a `MinFraud` object with the `custom_inputs` array set to `$values`. Existing `custom_inputs` data will be replaced.
withDevice()  : MinFraud
This returns a `MinFraud` object with the `device` array set to the values provided. Existing `device` data will be replaced.
withEmail()  : MinFraud
This returns a `MinFraud` object with the `email` array set to values provided. Existing `email` data will be replaced.
withEvent()  : MinFraud
This returns a `MinFraud` object with the `event` array set to the values provided. Existing `event` data will be replaced.
withOrder()  : MinFraud
This returns a `MinFraud` object with the `order` array set to the provided values. Existing `order` data will be replaced.
withPayment()  : MinFraud
This returns a `MinFraud` object with the `payment` array set to the values provided. Existing `payment` data will be replaced.
withShipping()  : MinFraud
This returns a `MinFraud` object with the `shipping` array set to the values provided. Existing `shipping` data will be replaced.
withShoppingCartItem()  : MinFraud
This returns a `MinFraud` object with the provided values added to the shopping cart array. Existing shopping cart data will be preserved.

Constants

Methods

__construct()

public __construct(int $accountId, string $licenseKey[, array<string, mixed> $options = [] ]) : mixed
Parameters
$accountId : int

Your MaxMind account ID

$licenseKey : string

Your MaxMind license key

$options : array<string, mixed> = []

An array of options. Possible keys:

  • host - The host to use when connecting to the web service. By default, the client connects to the production host. However, during testing and development, you can set this option to 'sandbox.maxmind.com' to use the Sandbox environment's host. The sandbox allows you to experiment with the API without affecting your production data.
  • userAgent - The prefix for the User-Agent header to use in the request.
  • caBundle - The bundle of CA root certificates to use in the request.
  • connectTimeout - The connect timeout to use for the request.
  • hashEmail - By default, the email address is sent in plain text. If this is set to true, the email address will be normalized and converted to an MD5 hash before the request is sent. The email domain will continue to be sent in plain text.
  • timeout - The timeout to use for the request.
  • proxy - The HTTP proxy to use. May include a schema, port, username, and password, e.g., http://username:password@127.0.0.1:10.
  • locales - An array of locale codes to use for the location name properties.
  • validateInput - Default is true. Determines whether values passed to the with*() methods are validated. It is recommended that you leave validation on while developing and only (optionally) disable it before deployment.

factors()

This method performs a minFraud Factors lookup using the request data in the current object and returns a model object for minFraud Factors.

public factors() : Factors
Tags
throws
InvalidInputException

when the request has missing or invalid data

throws
AuthenticationException

when there is an issue authenticating the request

throws
InsufficientFundsException

when your account is out of funds

throws
InvalidRequestException

when the request is invalid for some other reason, e.g., invalid JSON in the POST.

throws
HttpException

when an unexpected HTTP error occurs

throws
WebServiceException

when some other error occurs. This also serves as the base class for the above exceptions.

Return values
Factors

minFraud Factors model object

insights()

This method performs a minFraud Insights lookup using the request data in the current object and returns a model object for minFraud Insights.

public insights() : Insights
Tags
throws
InvalidInputException

when the request has missing or invalid data

throws
AuthenticationException

when there is an issue authenticating the request

throws
InsufficientFundsException

when your account is out of funds

throws
InvalidRequestException

when the request is invalid for some other reason, e.g., invalid JSON in the POST.

throws
HttpException

when an unexpected HTTP error occurs

throws
WebServiceException

when some other error occurs. This also serves as the base class for the above exceptions.

Return values
Insights

minFraud Insights model object

score()

This method performs a minFraud Score lookup using the request data in the current object and returns a model object for minFraud Score.

public score() : Score
Tags
throws
InvalidInputException

when the request has missing or invalid data

throws
AuthenticationException

when there is an issue authenticating the request

throws
InsufficientFundsException

when your account is out of funds

throws
InvalidRequestException

when the request is invalid for some other reason, e.g., invalid JSON in the POST.

throws
HttpException

when an unexpected HTTP error occurs

throws
WebServiceException

when some other error occurs. This also serves as the base class for the above exceptions.

Return values
Score

minFraud Score model object

with()

This returns a `MinFraud` object with the array to be sent to the web service set to `$values`. Existing values will be replaced.

public with(array<string, mixed> $values) : MinFraud
Parameters
$values : array<string, mixed>

The request as a structured array

Tags
link

minFraud API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withAccount()

This returns a `MinFraud` object with the `account` array set to the values provided. Existing `` data will be replaced.

public withAccount([array<string, mixed> $values = [] ][, string|null $userId = null ][, string|null $usernameMd5 = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of account data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$userId : string|null = null

a unique user ID associated with the end-user in your system

$usernameMd5 : string|null = null

an MD5 hash as a hexadecimal string of the username or login name associated with the account

Tags
link

minFraud account API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withBilling()

This returns a `MinFraud` object with the `billing` array set to `$values`. Existing `billing` data will be replaced.

public withBilling([array<string, mixed> $values = [] ][, string|null $address = null ][, string|null $address2 = null ][, string|null $city = null ][, string|null $company = null ][, string|null $country = null ][, string|null $firstName = null ][, string|null $lastName = null ][, string|null $phoneCountryCode = null ][, string|null $phoneNumber = null ][, string|null $postal = null ][, string|null $region = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of billing data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$address : string|null = null

The first line of the user's billing address

$address2 : string|null = null

The second line of the user's billing address

$city : string|null = null

The city of the user's billing address

$company : string|null = null

The company of the end user as provided in their billing information

$country : string|null = null

The two character ISO 3166-1 alpha-2 country code of the user's billing address

$firstName : string|null = null

The first name of the end user as provided in their billing information

$lastName : string|null = null

The last name of the end user as provided in their billing information

$phoneCountryCode : string|null = null

The country code for phone number associated with the user's billing address. If you provide this information then you must provide at least one digit.

$phoneNumber : string|null = null

The phone number without the country code for the user's billing address. Punctuation characters will be stripped. After stripping punctuation characters, the number must contain only digits.

$postal : string|null = null

The postal code of the user's billing address

$region : string|null = null

The ISO 3166-2 subdivision code for the user's billing address

Tags
link

minFraud billing API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withCreditCard()

This returns a `MinFraud` object with the `credit_card` array set to provided values. Existing `credit_card` data will be replaced.

public withCreditCard([array<string, mixed> $values = [] ][, string|null $avsResult = null ][, string|null $bankName = null ][, string|null $bankPhoneCountryCode = null ][, string|null $bankPhoneNumber = null ][, string|null $country = null ][, string|null $cvvResult = null ][, string|null $issuerIdNumber = null ][, string|null $lastDigits = null ][, string|null $token = null ][, bool|null $was3dSecureSuccessful = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of credit card data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$avsResult : string|null = null

The address verification system (AVS) check result, as returned to you by the credit card processor

$bankName : string|null = null

The name of the issuing bank as provided by the end user

$bankPhoneCountryCode : string|null = null

The phone country code for the issuing bank as provided by the end user

$bankPhoneNumber : string|null = null

The phone number, without the country code, for the issuing bank as provided by the end user

$country : string|null = null

The two character ISO 3166-1 alpha-2 country code where the issuer of the card is located

$cvvResult : string|null = null

The card verification value (CVV) code as provided by the payment processor

$issuerIdNumber : string|null = null

The issuer ID number for the credit card. This is the first six or eight digits of the credit card number. It identifies the issuing bank.

$lastDigits : string|null = null

The last digits of the credit card number. In most cases, you should send the last four digits for lastDigits.

$token : string|null = null

A token uniquely identifying the card

$was3dSecureSuccessful : bool|null = null

Whether the outcome of 3-D Secure verification was successful

Tags
link

minFraud credit_card API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withCustomInputs()

This returns a `MinFraud` object with the `custom_inputs` array set to `$values`. Existing `custom_inputs` data will be replaced.

public withCustomInputs(array<string, mixed> $values) : MinFraud
Parameters
$values : array<string, mixed>

the custom inputs to send in the request

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withDevice()

This returns a `MinFraud` object with the `device` array set to the values provided. Existing `device` data will be replaced.

public withDevice([array<string, mixed> $values = [] ][, string|null $acceptLanguage = null ][, string|null $ipAddress = null ][, float|null $sessionAge = null ][, string|null $sessionId = null ][, string|null $userAgent = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of device data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$acceptLanguage : string|null = null

The HTTP Accept-Language header of the device used in the transaction

$ipAddress : string|null = null

The IP address associated with the device used by the customer in the transaction. The IP address must be in IPv4 or IPv6 presentation format, i.e., dotted-quad notation or the IPv6 hexadecimal-colon notation.

$sessionAge : float|null = null

The number of seconds between the creation of the user's session and the time of the transaction. Note that session_age is not the duration of the current visit, but the time since the start of the first visit.

$sessionId : string|null = null

An ID that uniquely identifies a visitor's session on the site

$userAgent : string|null = null

The HTTP User-Agent header of the browser used in the transaction

Tags
link

minFraud device API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withEmail()

This returns a `MinFraud` object with the `email` array set to values provided. Existing `email` data will be replaced.

public withEmail([array<string, mixed> $values = [] ][, string|null $address = null ][, string|null $domain = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of email data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$address : string|null = null

The email address used in the transaction. This field must be a valid email address.

$domain : string|null = null

The domain of the email address used in the transaction. Do not include the @ in this field.

Tags
link

minFraud email API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withEvent()

This returns a `MinFraud` object with the `event` array set to the values provided. Existing `event` data will be replaced.

public withEvent([array<string, mixed> $values = [] ][, string|null $shopId = null ][, string|null $time = null ][, string|null $transactionId = null ][, string|null $type = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of event data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$shopId : string|null = null

Your internal ID for the shop, affiliate, or merchant this order is coming from. Required for minFraud users who are resellers, payment providers, gateways and affiliate networks. No specific format is required.

$time : string|null = null

The date and time the event occurred. The string must be in the RFC 3339 date-time format. The time must be within the past year. If this field is not in the request, the current time will be used.

$transactionId : string|null = null

Your internal ID for the transaction. We can use this to locate a specific transaction in our logs, and it will also show up in email alerts and notifications from us to you. No specific format is required.

$type : string|null = null

The type of event being scored. The valid types are:

  • account_creation
  • account_login
  • email_change
  • password_reset
  • payout_change
  • purchase
  • recurring_purchase
  • referral
  • survey
Tags
link

minFraud event API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withOrder()

This returns a `MinFraud` object with the `order` array set to the provided values. Existing `order` data will be replaced.

public withOrder([array<string, mixed> $values = [] ][, string|null $affiliateId = null ][, float|null $amount = null ][, string|null $currency = null ][, string|null $discountCode = null ][, bool|null $hasGiftMessage = null ][, bool|null $isGift = null ][, string|null $referrerUri = null ][, string|null $subaffiliateId = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of order data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$affiliateId : string|null = null

The ID of the affiliate where the order is coming from. No specific format is required.

$amount : float|null = null

The total order amount

$currency : string|null = null

The currency code for the order amount

$discountCode : string|null = null

The discount code applied to the order

$hasGiftMessage : bool|null = null

Indicates if the order has a gift message

$isGift : bool|null = null

Indicates if the order is a gift

$referrerUri : string|null = null

The URI of the referring website

$subaffiliateId : string|null = null

The ID of the sub-affiliate where the order is coming from. No specific format is required.

Tags
link

minFraud order API docs

see
https://support.maxmind.com/hc/en-us/articles/5452293435675-Order-and-Shopping-Cart-Inputs#h_01G0Z50Q0MRXQ5R52EF34E6G7J
Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withPayment()

This returns a `MinFraud` object with the `payment` array set to the values provided. Existing `payment` data will be replaced.

public withPayment([array<string, mixed> $values = [] ][, string|null $declineCode = null ][, string|null $processor = null ][, bool|null $wasAuthorized = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of payment data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$declineCode : string|null = null

The decline code as provided by your payment processor. If the transaction was not declined, do not include this field.

$processor : string|null = null

The payment processor used for the transaction

$wasAuthorized : bool|null = null

The authorization outcome from the payment processor. If the transaction has not yet been approved or denied, do not include this field.

Tags
link

minFraud payment API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withShipping()

This returns a `MinFraud` object with the `shipping` array set to the values provided. Existing `shipping` data will be replaced.

public withShipping([array<string, mixed> $values = [] ][, string|null $address = null ][, string|null $address2 = null ][, string|null $city = null ][, string|null $company = null ][, string|null $country = null ][, string|null $deliverySpeed = null ][, string|null $firstName = null ][, string|null $lastName = null ][, string|null $phoneCountryCode = null ][, string|null $phoneNumber = null ][, string|null $postal = null ][, string|null $region = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of shipping data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$address : string|null = null

The first line of the user's shipping address

$address2 : string|null = null
$city : string|null = null

The city of the user's shipping address

$company : string|null = null

The company of the end user as provided in their shipping information

$country : string|null = null

The two character ISO 3166-1 alpha-2 country code of the user's shipping address

$deliverySpeed : string|null = null
$firstName : string|null = null
$lastName : string|null = null
$phoneCountryCode : string|null = null
$phoneNumber : string|null = null
$postal : string|null = null

The postal code of the user's shipping address

$region : string|null = null

The ISO 3166-2 subdivision code for the user's shipping address

Tags
link

minFraud shipping API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.

withShoppingCartItem()

This returns a `MinFraud` object with the provided values added to the shopping cart array. Existing shopping cart data will be preserved.

public withShoppingCartItem([array<string, mixed> $values = [] ][, string|null $category = null ][, string|null $itemId = null ][, float|null $price = null ][, int|null $quantity = null ]) : MinFraud
Parameters
$values : array<string, mixed> = []

An array of shopping cart data. The keys are the same as the JSON keys. You may use either this or the named arguments, but not both.

$category : string|null = null

The category of the item. This can also be a hashed value; see below.

$itemId : string|null = null
$price : float|null = null

The per-unit price of this item in the shopping cart. This should use the same currency as the order currency.

$quantity : int|null = null

The quantity of the item in the shopping cart. The value must be a whole number.

Tags
link

minFraud shopping cart item API docs

Return values
MinFraud

A new immutable MinFraud object. This object is a clone of the original with additional data.


        
On this page

Search results