-
Add siftscience/sift-php as a dependency in composer.json.
"require": { ... "siftscience/sift-php" : "1.*" ... }
-
Run
composer update
. -
Now
SiftClient
will be autoloaded into your project.require 'vendor/autoload.php'; $sift = new SiftClient('my_api_key');
-
Download the latest release.
-
Extract into a folder in your project root named "sift-php".
-
Include
SiftClient
in your project like this:require 'sift-php/lib/Services_JSON-1.0.3/JSON.php'; require 'sift-php/lib/SiftRequest.php'; require 'sift-php/lib/SiftResponse.php'; require 'sift-php/lib/SiftClient.php'; require 'sift-php/lib/Sift.php'; $sift = new SiftClient('my_api_key');
Here's an example that sends a $transaction
event to sift.
$sift = new SiftClient('my_api_key');
$response = $sift->track('$transaction', array(
'$user_id' => '23056',
'$user_email' => 'buyer@gmail.com',
'$seller_user_id' => '2371',
'$seller_user_email' => 'seller@gmail.com',
'$transaction_id' => '573050',
'$currency_code' => 'USD',
'$amount' => 15230000,
'$time' => 1327604222,
'trip_time' => 930,
'distance_traveled' => 5.26,
));
$sift = new SiftClient('my_api_key');
$response = $sift->label('23056', array(
'$is_bad' => true,
'$reasons' => array('$chargeback')
));
$sift = new SiftClient('my_api_key');
$response = $sift->unlabel('23056');
$sift = new SiftClient('my_api_key');
$response = $sift->score('23056');
$response->body['score']; // => 0.030301357270181357
Run the tests from the project root with PHPUnit like this:
phpunit --bootstrap vendor/autoload.php test/SiftClientTest
-
Update
composer.json
to reflect the new version, as well as any new requirements then merge changes into master. -
Create a new release with the version number and use it as the description. Packagist will automatically deploy a new package via the configured webhook.
MIT