ueSecurityToken

Defines a source key used to identify a merchant or reseller.

Description

This object defines a source key which is used to identify the merchant or reseller making the request. Source keys are obtained by logging into the merchant or reseller console.

A source key that has a pin assigned must include the Hash object. It is highly recommended that a pin always be used in conjunction with the source key.

All SOAP methods require the use of a pin, except the following transaction methods:

* runTransactionApi
* runTransaction
* runSale
* runQuickSale
* runCredit
* authOnly
* postAuth
* captureTransaction

The ClientIP is used to reference the end client. While this field is not required (it can be left blank) it is used by several fraud modules and is recommended.

Properties

Type Name Description
string SourceKey SourceKey obtained in merchant console.
ueHash PinHash Hash object for the PIN (only necessary if this source key has a pin assigned)
string ClientIP The IP Address of the end client

Examples

PHP 5

    <?php
    class TokenClientExample {

        public $client; // initialize client
        public $token;// initialize token

        function setUp{
            $client=self::getClient(); //Using this class
            $token=self::getToken();   //Using this class
        }

        static function getClient(){
            //for live server use 'www' for test server use 'sandbox'
            $wsdl='https://secure.newtekgateway.com/soap/resellerapi/1412E031/newtek.wsdl';

            return new SoapClient($wsdl,array("trace"=>1,"exceptions"=>1));
            //Must have Php5 compiled with --enable-soap
            *Otherwise use pear soap. For more info please visit: http:*pear.php.net/package/SOAP
        }

        static function getToken(){
            // Creating a ueSecurityToken

            $sourcekey = 'yQbOFkmykeygoeshere3Lc9PH1l14';
    //Input your merchant console generated source key
            $pin = '1234'; //Input the PIN set in the source editor for your source key

            // generate random seed value
            $seed=mktime() . rand();

            // make hash value using sha1 function
            $clear= $sourcekey . $seed . $pin;
            $hash=sha1($clear);

            // assembly ueSecurityToken as an array
            // (php5 will correct the type for us)
            $tok=array(
             'SourceKey'=>$sourcekey,
             'PinHash'=>array(
                'Type'=>'sha1',
                'Seed'=>$seed,
                'HashValue'=>$hash
                ),
             'ClientIP'=>'192.168.0.1'
            );
            return $tok;
        }
    }
    ?>

PHP 4

    <?php

    // Creating a ueSecurityToken
    $sourcekey = 'yQbOFkjD8wwlkZ3AhY248k3Lc9PH1l14';
    $pin = '1234';

    // generate random seed value
    $seed=mktime() . rand();

    // make hash value using sha1 function
    $clear= $sourcekey . $seed . $pin;
    $hash=sha1($clear);

    // assembly ueSecurityToken as an array
    // (php4 will correct the type for us)
    $token=array(
     'SourceKey'=>$sourcekey,
     'PinHash'=>array(
            'Type'=>'sha1',
            'Seed'=>$seed,
            'HashValue'=>$hash
            ),
     'ClientIP'=>'192.168.0.1'
    );


    ?>

Visual Basic .Net

    Imports System
    Imports System.Web
    Imports System.IO
    Imports System.Security.Cryptography
    Imports System.Text

    Private Sub mySoapCall()

      Dim token As newtek.ueSecurityToken
      Dim hash As newtek.ueHash = New newtek.ueHash
      Dim sourcekey As String
      Dim pin As String

      ' The source key and pin are created by the merchant
      sourcekey = "e42SYc86C4uvlvyP62ow54Kv93SZsJVm"
      pin = "1234"

      token = New newtek.ueSecurityToken
      token.SourceKey = sourcekey

      ' To create the hash we must concat the sourcekey, seed and pin
      Dim rand As System.Random = New System.Random
      hash.Seed = Date.Now.ToUniversalTime & rand.Next()

      Dim prehashvalue As String
      prehashvalue = sourcekey & hash.Seed & pin

      ' Generate the md5 hash
      hash.Type = "md5"
      hash.HashValue = GenerateHash(prehashvalue)
      token.PinHash = hash

    End Sub





    Private Function GenerateHash(ByVal SourceText As String) As String
      'Instantiate an MD5 Provider object
      Dim md5 As New MD5CryptoServiceProvider

      'Compute the hash value from the source
      Dim ByteHash() As Byte = md5.ComputeHash(Encoding.Default.GetBytes(SourceText))

      'Instantiate a StringBuilder object
      Dim sb As New StringBuilder

      'Repack binary hash as hex
      For c As Integer = 0 To ByteHash.Length - 1
        sb.AppendFormat("{0:x2}", ByteHash(c))
      Next c

      'Return the hex hash
      Return sb.ToString
    End Function

Coldfusion

NOTE: this example has not been tested and is provided as is.

    `<cfscript>`
      seed = randrange(0, 1000000);
      pin = 'yourpin';
      Token = structnew ();
      Token.SourceKey = 'yoursourcekey here';
      Token.PinHash = structnew();
      Token.PinHash.Type = 'md5';
      Token.PinHash.Seed = #seed#;
      Token.PinHash.HashValue = hash('#Token.SourceKey#'&'#Token.PinHash.Seed#'&'#pin#');
    `</cfscript>`