FylmTM
Maxmind API library
Author: Dmitry Vrublevskis
Email: d.vrublevskis@gmail.com
Recommended way of installation is through composer. Add to your composer.json:
"require": {
"fylmtm/maxmind-api": "0.1.*@dev"
}
And then install with:
$ composer.phar install
You can manually download library and use autoloader.
require_once 'lib/autoloader.php'
Create client:
$fraudClient = new Maxmind\MinFraud\MinFraudClient();
By default main server used. You can choose whatever you want:
$fraudClient->setServer(\Maxmind\MinFraud\MinFraudServers::MAIN);
$fraudClient->setServer(\Maxmind\MinFraud\MinFraudServers::US_EAST);
$fraudClient->setServer(\Maxmind\MinFraud\MinFraudServers::US_WEST);
HTTPS used by default. You can turn on/off https usage:
$fraudClient->enableHttps(false);
You need to create request, which you pass to fraudClient later. Required request fields must be passed on client creation. By default standard
request type used.
// Exception may be thrown, if any of required fields will not be passed.
$request = new Maxmind\MinFraud\MinFraudRequest([
'license_key' => '1111111',
'i' => '257.257.257.257',
'city' => 'BigApple',
'region' => 'NA',
'postal' => '1111',
'country' => 'NA',
]);
$request->setRequestType('standard'); // 'standard' or 'premium' request type can be used.
Other fields (see API reference for more info) can be passed separately.
$request->setShippingAddress([
'shipAddr' => '',
'shipCity' => '',
'shipRegion' => '',
'shipPostal' => '',
'shipCountry' => ''
]);
$request->setUserData([
'domain' => '',
'custPhone' => '',
'emailMD5' => '',
'usernameMD5' => '',
'passwordMD5' => ''
]);
$request->setBinRelated([
'bin' => '',
'binName' => '',
'binPhone' => ''
]);
$request->setTransactionLinking([
'sessionID' => '',
'user_agent' => '',
'accept_language' => ''
]);
$request->setTransactionInformation([
'txnID' => '',
'order_amount' => '',
'order_currency' => '',
'shopID' => '',
'txn_type' => ''
]);
$request->setCreditCardCheck([
'avs_result' => '',
'cvv_result' => ''
]);
$request->setMisc([
'forwardedIP' => ''
]);
Request can be executed via client.
$response = $fraudClient->executeRequest($request);
$response->getIsCurlSuccessful(); // true|false - indicates if curl was successfull
$response->getRawResult(); // string - raw curl response, contains error if curl was unsuccessful
$response->getResult(); // parsed minFraud response
If you wish to run tests, you need to install development dependencies:
$ composer.phar install --dev
And then run them with:
$ vendor/bin/phpunit