fylmtm / maxmind-api
Maxmind API library
Installs: 10 315
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: 3.7.*
- satooshi/php-coveralls: dev-master
This package is auto-updated.
Last update: 2020-02-05 22:55:57 UTC
README
About
Author: Dmitry Vrublevskis
Email: d.vrublevskis@gmail.com
Installation
Composer
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
Manual
You can manually download library and use autoloader.
require_once 'lib/autoloader.php'
Usage
MinFraud client
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);
MinFraud request
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' => '' ]);
MinFraud response
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
Tests
If you wish to run tests, you need to install development dependencies:
$ composer.phar install --dev
And then run them with:
$ vendor/bin/phpunit