Giter Site home page Giter Site logo

inspetor-php's Introduction

Inspetor Logo

Description

Inspetor is a product developed to help your company to avoid fraudulent transactions. This repository contains the PHP SDK for you to integrate into your company's PHP services, which will allow Inspetor to analyze user patterns and prevent fraudulent transactions. This README file, along with our generalized integration documentation are here to help you to integrate the Inspetor PHP library into your product with few easy steps.

Setup Guide

This is the step-by-step Inspetor integration:

Composer & Packagist

We recommend using Composer to add the Inspetor SDK to your PHP project's dependencies. The Inspetor SDK is available on Packagist, or directly on GitHub.

You can add the Inspetor SDK to your Composer-managed PHP project as follows:

composer require inspetor/inspetor-php:${VERSION}

Following this command, the Inspetor SDK should be listed in your composer.json 'require' block and the package source files should be present in your vendor folder.

SDK setup

To instantiate the Inspetor client object within your project, you'll need to perform some minimal configuration. We suggest adding a similar block to your application configuration:

'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.
]

We suggest creating an Inspetor class in which to instantiate you InspetorClient, then provide the instantiated client object to your various internal clients. This will ensure that your InspetorClient object has been properly configured prior to being called:

<?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;
    }
}
?>

Using the Inspetor client

Detailed method information and language-specific examples are all available in the Inspetor integration documentation. There you will find definitions, examples, and references for fundamental Inspetor entities. But just to get you started, we'll provide a practical example for interacting with our SDK below.

Let's imagine that you want to put a tracker in your "create transaction" flow to send analytic information to Inspetor at sale creation time. As you may have guessed (if you've read the docs), you'll be calling the inspetorSaleCreation method.

Naturally, the inspetorSaleCreation method requires certain characteristics of the sale creation to be send to Inspetor for analysis. Those attributes are captured in a model (specifically, the InspetorSale model). You can find more general information on Inspetor's concept of models here.

Here's an example of how you would integrate this into your code base:

<?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;
  }
  ...
}

?>

Note that we are using an auxiliar function inspetorSaleBuilder to build the Sale Model. This is not strictly necessary, but we imagine you will find such a practice preferable.

Support

Feel free to reach out to the Inspetor team if you encounter any problems during your integration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.