Skip to content

Example Usage

preslav-anev edited this page Jun 27, 2017 · 11 revisions

Once settings.ini file is in place, proceed with the following.

  1. Wrap the code inside of a try-catch block.
  2. Create a Kount_Ris_Request_Inquiry object or Kount_Ris_Request_Update object depending on if you are sending an initial request or updating a previous transaction.
  3. Call the setters required for the inquiry or update mode (Q is the default for inquiries and U is the default for updates).
  4. Call getResponse() on the inquiry or update object. A populated Kount.Ris.Response object will be returned. The Kount_Ris_Response object has many getters for using the RIS data.

Once a successful inquiry is made, incorporate as many additional setters to the object as are available before calling getResponse(). The more data provided in the object, the more accurate the risk assessment.

The following is sample code that illustrates these steps:

  <?php

   // RIS request --- requires curl support enabled in PHP
   // php_mbstring support enabled in your php.ini file
  
  // If using Direct Download
  require __DIR__ . 'path-to-sdk/src/autoload.php';

  //  OR

  // If using Composer installation
  require __DIR__ . './vendor/autoload.php';

  // Minimal RIS inquiry example:
  try {
    $inquiry = new Kount_Ris_Request_Inquiry();

    $inquiry->setSessionId('session-id-max-32-chars');
    $inquiry->setPayment('CARD', '4111111111111111');
   
    $inquiry->setTotal(500);
    $inquiry->setEmail('[email protected]');
    $inquiry->setIpAddress('192.168.0.21');
    $inquiry->setMack('Y');
    $inquiry->setWebsite("DEFAULT");
    $cart = array();
    $cart[] = new Kount_Ris_Data_CartItem("TV", "LZG-123", "32-inch LCD", 1, 129999);
    $inquiry->setCart($cart);
    $inquiry->setAuth('A');
   
    // additional optional setters..
    // setGender value can be either "M" or "F"

    $inquiry->setGender("M");
    $inquiry->setDateOfBirth("2017-03-12");

    $response = $inquiry->getResponse();
    // optional getter
    $warnings = $response->getWarnings();

    print_r($response);

    $score = $response->getScore();
    $auto = $response->getAuto();

  } catch (Exception $e) {
    print_r($e);
    // handle exception
  }

Next Step