2017 © Pedro PelĂĄez
 

library bayonet-php

Bayonet PHP library

image

bayonet/bayonet-php

Bayonet PHP library

  • Monday, March 26, 2018
  • by imran-bayonet
  • Repository
  • 1 Watchers
  • 2 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Latest Stable Version License, (*1)

Bayonet

Bayonet enables companies to feed and consult a global database about online consumers’ reputation, based on historic payments. Start making smarter business decisions today., (*2)

Introduction

Bayonet’s API is organized around REST and exposes endpoints for HTTP requests. It is designed to have predictable, resource-oriented URLs and uses standard HTTP response codes to indicate the outcome of operations. Request and response payloads are formatted as JSON., (*3)

About the service

Bayonet provides an Ecosystem of Trust and Protection where companies can collaborate with each other to combat online fraud together. We provide a secure platform to share and consult data to understand when a consumer is related to fraudulent activity or has a fraud-free record. Different technologies that run algorithms to link parameters seen in different transactions, fed by companies connected to the ecosystem are employed in order to build consumer profiles. By consulting Bayonet’s API, a response with data provided by companies themselves is available in real-time for your risk assesment process to analyze it and take better decisions., (*4)

Bayonet's API details

The examples shown in this README are only for demonstration of the functionality of this SDK. For the detailed integration flow, and when to send which API call, please refer to the Bayonet API documentation., (*5)

Getting started

Requirements

To use this SDK, please make sure: * You have PHP 5.4 or superior installed on your system. * You have an API KEY (sandbox and/or live) provided by Bayonet's team., (*6)

Composer

  1. Add dependency 'bayonet-php' in your composer.json file, (*7)

    "require": {
        ...
        "bayonet/bayonet-php": "2.0.*"
        ...
    }
    

    Run composer to get the dependencies, (*8)

    composer update
    
  2. Load the dependencies using Composer autoload, (*9)

    require_once('vendor/autoload.php');
    

Manual Installation

  1. If you do not use Composer, download the latest release. Extract into your project root into a folder named bayonet-php. Use the init.php file to load the Bayonet dependencies, (*10)

    require 'bayonet-php/init.php';
    
  2. BayonetClient uses Guzzle as dependency. Make sure you download and include Guzzle into your project as well, (*11)

    require 'guzzle/autoloader.php';
    

    If you use Composer, the above dependency will be handled automatically. If you choose manual installation, you will need to make sure the dependency is available., (*12)

Usage

Once you have Bayonet's SDK configured, you can call the APIs with the following syntax. Follow the guidelines specific to the product you are integrating:, (*13)

Ecommerce

  • Initialize the Ecommerce client, (*16)

    $bayonet = new Bayonet\EcommerceClient([
      'api_key' => 'your_api_key',
      'version' => 2
    ]);
    

    You can use environment vars to load the api key too, (*17)

    export BAYONET_API_KEY=your_api_key
    
  • Consult API, (*18)

    $bayonet->consult([
      'body' => [
        'channel' => 'ecommerce',
        'email' => 'example@bayonet.io',
        'consumer_name' => 'Example name',
        'consumer_internal_id' => '<your internal ID for this consumer>',
        'cardholder_name' => 'Example name',
        'telephone' => '1234567890',
        'card_number' => '4111111111111111',
        'transaction_amount' => 999.00,
        'currency_code' => 'MXN',
        'shipping_address' => [
          'line_1' => 'example line 1',
          'line_2' => 'example line 2',
          'city' => 'Mexico City',
          'state' => 'Mexico DF',
          'country' => 'MEX',
          'zip_code' => '64000'
        ],
        'billing_address' => [
          'line_1' => 'example line 1',
          'line_2' => 'example line 2',
          'city' => 'Mexico City',
          'state' => 'Mexico DF',
          'country' => 'MEX',
          'zip_code' => '64000'
        ],
        'payment_method' => 'card',
        'order_id' => '<your internal ID for this order>',
        'transaction_id' => '<your internal ID for this transaction>',
        'payment_gateway' => 'stripe',
        'coupon' => 'discount_buen_fin',
        'expedited_shipping' => true,
        'products' => [
          [
            'product_id' => '1',
            'product_name' => 'product_1',
            'product_price' => 500.00,
            'product_category' =>'example category'
          ],
          [
            'product_id' => '2',
            'product_name' => 'product_2',
            'product_price' => 499.00,
            'product_category' =>'example category'
          ]
        ],
        'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>'
      ],
      'on_success' => function($response) {
        print_r($response);
      },
      'on_failure' => function($response) {
        print_r($response);
      }
    ]);
    
  • Update Transaction API, (*19)

    $bayonet->update_transaction([
      'body' => [
        'transaction_status' => 'success',
        'transaction_id' => '<your internal ID for this transaction (as sent in the consult step)>',
        ...
      ],
      'on_success' => function($response) {
        print_r($response);
      },
      'on_failure' => function($response) {
        print_r($response);
      }
    ]);
    
  • Feedback-historical API, (*20)

    $bayonet->feedback_historical([
      'body' => [
        'channel' => 'ecommerce',
        'email' => 'example@bayonet.io',
        'consumer_name' => 'Example name',
        'consumer_internal_id' => '<your internal ID for this consumer>',
        'cardholder_name' => 'Example name',
        'telephone' => '1234567890',
        'card_number' => '4111111111111111',
        'transaction_amount' => 999.00,
        'currency_code' => 'MXN',
        'shipping_address' => [
          'line_1' => 'example line 1',
          'line_2' => 'example line 2',
          'city' => 'Mexico City',
          'state' => 'Mexico DF',
          'country' => 'MEX',
          'zip_code' => '64000'
        ],
        'billing_address' => [
          'line_1' => 'example line 1',
          'line_2' => 'example line 2',
          'city' => 'Mexico City',
          'state' => 'Mexico DF',
          'country' => 'MEX',
          'zip_code' => '64000'
        ],
        'payment_method' => 'card',
        'transaction_id' => '<your internal ID for this transaction>',
        'payment_gateway' => 'stripe',
        'coupon' => 'discount_buen_fin',
        'expedited_shipping' => true,
        'products' => [
          [
            'product_id' => '1',
            'product_name' => 'product_1',
            'product_price' => 500.00,
            'product_category' =>'example category'
          ],
          [
            'product_id' => '2',
            'product_name' => 'product_2',
            'product_price' => 499.00,
            'product_category' =>'example category'
          ]
        ],
        'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>',
        'transaction_time' => 1476012879,
        'transaction_status' => 'success',
      ],
      'on_success' => function($response) {
          print_r($response);
      },
      'on_failure' => function($response) {
          print_r($response);
      }
    ]);
    

Lending

  • Initialize the Lending client, (*21)

    php $bayonet = new Bayonet\LendingClient([ 'api_key' => 'your_api_key', 'version' => 2 ]); You can use environment vars to load the api key too, (*22)

    sh export BAYONET_API_KEY=your_api_key, (*23)

  • Report Transaction (Request for loan received), (*24)

    $bayonet->report_transaction([
      'body' => [
        'email' => 'example@bayonet.io',
        'consumer_name' => 'Example name',
        'consumer_internal_id' => '<your internal ID for this consumer>',
        'telephone_fixed' => '1234567890',
        'telephone_mobile' => '1234567891',
        'telephone_reference_1' => '1234567892',
        'telephone_reference_2' => '1234567893',
        'telephone_reference_3' => '1234567894',
        'rfc' => 'Example RFC',
        'curp' => 'Example CURP',
        'clabe' => 'Example CLABE',
        'address' => [
          'line_1' => 'example line 1',
          'line_2' => 'example line 2',
          'city' => 'Mexico City',
          'state' => 'Mexico DF',
          'country' => 'MEX',
          'zip_code' => '64000'
        ],
        'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>',
        'transaction_category' => 'p2p_lending',
        'transaction_id' => '<your internal ID for this transaction>',
        'transaction_time' => 1476012879
      ],
      'on_success' => function($response) {
        print_r($response);
      },
      'on_failure' => function($response) {
        print_r($response);
      }
    ]);
    
  • Report Transaction (Request for loan received) + Consult, (*25)

    This lets you report a transaction (solicitud) and consult Bayonet at the same time. The only difference from the above method (Report Transaction) is that this method will also return a consult response, (*26)

    $bayonet->report_transaction_and_consult([
      'body' => [
        'email' => 'example@bayonet.io',
        'consumer_name' => 'Example name',
        'consumer_internal_id' => '<your internal ID for this consumer>',
        'telephone_fixed' => '1234567890',
        'telephone_mobile' => '1234567891',
        'telephone_reference_1' => '1234567892',
        'telephone_reference_2' => '1234567893',
        'telephone_reference_3' => '1234567894',
        'rfc' => 'Example RFC',
        'curp' => 'Example CURP',
        'clabe' => 'Example CLABE',
        'address' => [
          'line_1' => 'example line 1',
          'line_2' => 'example line 2',
          'city' => 'Mexico City',
          'state' => 'Mexico DF',
          'country' => 'MEX',
          'zip_code' => '64000'
        ],
        'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>',
        'transaction_category' => 'p2p_lending',
        'transaction_id' => '<your internal ID for this transaction>',
        'transaction_time' => 1476012879
      ],
      'on_success' => function($response) {
        print_r($response);
      },
      'on_failure' => function($response) {
        print_r($response);
      }
    ]);
    
  • Consult (consult the persona present in the transaction), (*27)

    $bayonet->consult([
      'body' => [
        'transaction_id' => '<transaction ID that you used when reporting the transaction or solicitud>'
      ],
      'on_success' => function($response) {
        print_r($response);
      },
      'on_failure' => function($response) {
        print_r($response);
      }
    ]);
    
  • Feedback (send feedback regarding a transaction - raise alert or block the user), (*28)

    $bayonet->feedback([
      'body' => [
        'transaction_id' => '<transaction ID that you used when reporting the transaction or solicitud>',
        'actions' => [
          'alert' => true,
          'block' => true
        ]
      ],
      'on_success' => function($response) {
        print_r($response);
      },
      'on_failure' => function($response) {
        print_r($response);
      }
    ]);
    
  • Feedback historical (for reporting historical transactions that were not sent to Bayonet), (*29)

    php $bayonet->feedback_historical([ 'body' => [ 'email' => 'example@bayonet.io', 'consumer_name' => 'Example name', 'consumer_internal_id' => '<your internal ID for this consumer>', 'telephone_fixed' => '1234567890', 'telephone_mobile' => '1234567891', 'telephone_reference_1' => '1234567892', 'telephone_reference_2' => '1234567893', 'telephone_reference_3' => '1234567894', 'rfc' => 'Example RFC', 'curp' => 'Example CURP', 'clabe' => 'Example CLABE', 'address' => [ 'line_1' => 'example line 1', 'line_2' => 'example line 2', 'city' => 'Mexico City', 'state' => 'Mexico DF', 'country' => 'MEX', 'zip_code' => '64000' ], 'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>', 'transaction_category' => 'p2p_lending', 'transaction_id' => '<your internal ID for this transaction>', 'transaction_time' => 1476012879, 'actions' => [ 'alert' => true, 'block' => true ] ], 'on_success' => function($response) { print_r($response); }, 'on_failure' => function($response) { print_r($response); } ]);, (*30)

Device Fingerprint

  • Initialize the Device Fingerprint client, (*31)

    php $bayonet = new Bayonet\DeviceFingerprintClient([ 'api_key' => 'your_api_key', 'version' => 2 ]); You can use environment vars to load the api key too sh export BAYONET_API_KEY=your_api_key, (*32)

  • Get-fingerprint-data API You can use this endpoint to get detailed information about a fingerprint generated by the Bayonet fingerprinting JS installed on your front-end, (*33)

    $bayonet->get_fingerprint_data([
        'body' => [
            'bayonet_fingerprint_token' => 'fingerprint-token-generated-by-JS-snipppet'
        ],
        'on_success' => function($response) {
            print_r($response);
        },
        'on_failure' => function($response) {
            print_r($response);
        }
    ]);
    

Success and error handling

Bayonet's SDK supports callbacks for success and error handling php // make the request $bayonet -> <EVENT>([ 'body' => ..., 'on_success' => function($response) { print_r($response); }, 'on_failure' => function($response) { print_r($response); } ]); ?> For a full list of error codes and their messages, please refer to the Bayonet API documentation., (*34)

Testing

You can run the test suite with the following command:, (*35)

./vendor/bin/phpunit tests

The Versions

26/03 2018

dev-master

9999999-dev https://bayonet.io

Bayonet PHP library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luis Herrada
by Imran Arshad

php anti-fraud bayonet

26/03 2018

dev-develop

dev-develop https://bayonet.io

Bayonet PHP library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luis Herrada
by Imran Arshad

php anti-fraud bayonet

26/03 2018

2.0.0

2.0.0.0 https://bayonet.io

Bayonet PHP library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luis Herrada
by Imran Arshad

php anti-fraud bayonet

05/06 2017

1.1.0

1.1.0.0 https://bayonet.io

Bayonet PHP library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luis Herrada
by Imran Arshad

php anti-fraud bayonet

20/01 2017

1.0.0

1.0.0.0 https://bayonet.io

Bayonet PHP library

  Sources   Download

MIT

The Requires

 

by Luis Herrada
by Imran Arshad

php anti-fraud bayonet