inspetor / inspetor-php
Inspetor反欺诈PHP库
Requires
- php: >=7.1.3
- snowplow/snowplow-tracker: 0.2.1
Requires (Dev)
- phpunit/phpunit: 5.7.*
- dev-master
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feature/update-account-model
- dev-feature/new-track-login
- dev-feature/add-snowplow-manager
- dev-feature/fraud-mark-discussion
- dev-feature/login-attempt-track
- dev-feature/change-client-config
- dev-feature/models-requirements-update
- dev-feature/improve-unittests
- dev-feature/models-major-fixes
- dev-feature/timestamp-integer
- dev-feature/lib-improvement
- dev-dev
- dev-feature/new-unit-tests
- dev-feature/new-inspetor-service
- dev-feature/new-inspetor-client
- dev-feature/new-action-functions
- dev-feature/base64-every-propertie
- dev-feature/datetime-formatter
- dev-feature/new-abstract-class-model
- dev-feature/new-inspetor-models
This package is auto-updated.
Last update: 2020-06-07 19:44:09 UTC
README
描述
Inspetor是一款帮助您的公司避免欺诈交易的产品。此存储库包含PHP SDK,您可以将它集成到公司的PHP服务中,这将允许Inspetor分析用户模式并防止欺诈交易。此README文件以及我们的通用集成文档旨在帮助您通过几个简单的步骤将Inspetor PHP库集成到产品中。
设置指南
这是Inspetor集成的逐步说明
Composer & Packagist
我们建议使用Composer将Inspetor SDK添加到您的PHP项目的依赖项中。Inspetor SDK在Packagist上可用,或在GitHub上直接可用。
您可以将Inspetor SDK添加到Composer管理的PHP项目中,如下所示
composer require inspetor/inspetor-php:${VERSION}
运行此命令后,Inspetor SDK应列在您的composer.json 'require'块中,并且包源文件应存在于您的vendor文件夹中。
SDK设置
为了在您的项目中实例化Inspetor客户端对象,您需要进行一些基本配置。我们建议将类似的块添加到您的应用程序配置中
'inspetor_config' => [
'trackerName' => company.service_name // provided by Inspetor
'appId' => unique.number // provided by Inspetor
'devEnv' => false // whether or not the data sent from this tracker should be considered production or not.
]
我们建议创建一个Inspetor
类,在其中实例化InspetorClient
,然后将实例化的客户端对象提供给您的各种内部客户端。这将确保在调用之前,您的InspetorClient
对象已正确配置
<?php
namespace NiceCompany\Inspetor;
use Inspetor\InspetorClient;
class Inspetor
{
public function __construct()
{
$this->inspetor = new InspetorClient($inspetor_config);
}
/**
* @return Inspetor\InspetorClient $client
*/
public function getClient() {
return $this->inspetor;
}
}
?>
使用Inspetor客户端
详细的方法信息和特定语言的示例都可在Inspetor集成文档中找到。在那里,您将找到基本Inspetor实体的定义、示例和参考。但为了让您开始,我们将提供一个与SDK交互的实际示例。
让我们假设您想在"创建交易"流程中放置一个跟踪器,以便在创建销售时向Inspetor发送分析信息。正如您可能猜测的(如果您已经阅读了文档),您将调用inspetorSaleCreation
方法。
当然,inspetorSaleCreation
方法需要发送销售创建的某些特征以供Inspetor分析。这些属性被捕获在一个模型中(具体来说,是InspetorSale模型)。有关Inspetor的模型概念的更多信息,请参阅这里。
以下是如何将此集成到您的代码库中的示例
<?php
namespace NiceCompany\SaleFolder;
use NiceCompany\Inspetor\InspetorClass;
class Sale {
...
public function createSale() {
// $company_sale is an example object of the company with sale data
$inspetor_sale = $this->inspetorSaleBuilder($company_sale);
$this->inspetor = new Inspetor();
$inspetor->getClient()->trackSaleCreation($inspetor_sale);
}
public function inspetorSaleBuilder($company_sale) {
$model = $this->inspetor->getClient()->getInspetorSale();
$model->setId($company_sale->getId());
$model->setAccountId($company_sale->getUserId());
$model->setStatus($company_sale->getSaleStatus());
$model->setIsFraud($company_sale->getFraud());
$model->set...
return $model;
}
...
}
?>
请注意,我们使用了一个辅助函数inspetorSaleBuilder来构建Sale Model。这并非绝对必要,但我们想象您会发现这种做法更可取。
支持
如果在集成过程中遇到任何问题,请随时联系Inspetor 团队。