PHP code example of maxmind / minfraud

1. Go to this page and download the library: Download maxmind/minfraud library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maxmind / minfraud example snippets






$mf = new MinFraud(1, 'ABCD567890', [ 'host' => 'sandbox.maxmind.com' ]);


axMind\MinFraud;

# The constructor for MinFraud takes your account ID, your license key, and
# optionally an array of options.
$mf = new MinFraud(1, 'ABCD567890');

# Note that each ->with*() call returns a new immutable object. This means
# that if you separate the calls into separate statements without chaining,
# you should assign the return value to a variable each time.
$request = $mf->withDevice([
    'ip_address'  => '152.216.7.110',
    'session_age' => 3600.5,
    'session_id'  => 'foobar',
    'user_agent'  =>
        'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
    'accept_language' => 'en-US,en;q=0.8',
])->withEvent([
    'transaction_id' => 'txn3134133',
    'shop_id'        => 's2123',
    'time'           => '2012-04-12T23:20:50+00:00',
    'type'           => 'purchase',
])->withAccount([
    'user_id'      => 3132,
    'username_md5' => '4f9726678c438914fa04bdb8c1a24088',
])->withEmail([
    'address' => '[email protected]',
    'domain'  => 'maxmind.com',
])->withBilling([
    'first_name'         => 'First',
    'last_name'          => 'Last',
    'company'            => 'Company',
    'address'            => '101 Address Rd.',
    'address_2'          => 'Unit 5',
    'city'               => 'New Haven',
    'region'             => 'CT',
    'country'            => 'US',
    'postal'             => '06510',
    'phone_number'       => '123-456-7890',
    'phone_country_code' => '1',
])->withShipping([
    'first_name'         => 'ShipFirst',
    'last_name'          => 'ShipLast',
    'company'            => 'ShipCo',
    'address'            => '322 Ship Addr. Ln.',
    'address_2'          => 'St. 43',
    'city'               => 'Nowhere',
    'region'             => 'OK',
    'country'            => 'US',
    'postal'             => '73003',
    'phone_number'       => '123-456-0000',
    'phone_country_code' => '1',
    'delivery_speed'     => 'same_day',
])->withPayment([
    'processor'             => 'stripe',
    'was_authorized'        => false,
    'decline_code'          => 'invalid number',
])->withCreditCard([
    'issuer_id_number'         => '411111',
    'last_digits'              => '7643',
    'bank_name'                => 'Bank of No Hope',
    'bank_phone_country_code'  => '1',
    'bank_phone_number'        => '123-456-1234',
    'avs_result'               => 'Y',
    'cvv_result'               => 'N',
    'was_3d_secure_successful' => true,
])->withOrder([
    'amount'           => 323.21,
    'currency'         => 'USD',
    'discount_code'    => 'FIRST',
    'is_gift'          => true,
    'has_gift_message' => false,
    'affiliate_id'     => 'af12',
    'subaffiliate_id'  => 'saf42',
    'referrer_uri'     => 'http://www.amazon.com/',
])->withShoppingCartItem([
    'category' => 'pets',
    'item_id'  => 'leash-0231',
    'quantity' => 2,
    'price'    => 20.43,
])->withShoppingCartItem([
    'category' => 'beauty',
    'item_id'  => 'msc-1232',
    'quantity' => 1,
    'price'    => 100.00,
])->withCustomInputs([
    'section'            => 'news',
    'previous_purchases' => 19,
    'discount'           => 3.2,
    'previous_user'      => true,
]);

# To get the minFraud Factors response model, use ->factors():
$factorsResponse = $request->factors();

print($factorsResponse->subscores->emailAddress . "\n");

# To get the minFraud Insights response model, use ->insights():
$insightsResponse = $request->insights();

print($insightsResponse->riskScore . "\n");
print($insightsResponse->creditCard->issuer->name . "\n");

foreach ($insightsResponse->warnings as $warning) {
    print($warning->warning . "\n");
}

# To get the minFraud Score response model, use ->score():
$scoreResponse = $request->score();

print($scoreResponse->riskScore . "\n");

foreach ($scoreResponse->warnings as $warning) {
    print($warning->warning . "\n");
}


axMind\MinFraud\ReportTransaction;

# The constructor for ReportTransaction takes your account ID, your license key,
# and optionally an array of options.
$rt = new ReportTransaction(1, 'ABCD567890');

$rt->report([
    'ip_address'      => '152.216.7.110',
    'tag'             => 'chargeback',
    'chargeback_code' => 'UA02',
    'minfraud_id'     => '26ae87e4-5112-4f76-b0f7-4132d45d72b2',
    'maxmind_id'      => 'aBcDeFgH',
    'notes'           => 'Found due to non-existent shipping address',
    'transaction_id'  => 'cart123456789',
]);
bash
curl -sS https://getcomposer.org/installer | php

php composer.phar 

PHP Fatal error:  Uncaught Error: Call to undefined function MaxMind\WebService\curl_version()