|
— |
developer:soap-1.6:objects:uesecuritytoken [2012/07/03 09:59] (current) tem created |
| | + | <embed ..:contents/>====== 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 | |
| | + | |
| | + | |
| | + | |
| | + | ===== Object Diagram ===== |
| | + | |
| | + | {{..:objects:uesecuritytoken.jpg|}} |
| | + | |
| | + | ===== Examples ===== |
| | + | |
| | + | ==== PHP 5 ==== |
| | + | |
| | + | <code php> |
| | + | <?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://www.usaepay.com/soap/gate/131C979E/usaepay.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; |
| | + | } |
| | + | } |
| | + | ?> |
| | + | </code> |
| | + | |
| | + | ==== PHP 4 ==== |
| | + | |
| | + | <code php> |
| | + | <?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' |
| | + | ); |
| | + | |
| | + | |
| | + | ?> |
| | + | </code> |
| | + | |
| | + | |
| | + | ==== Visual Basic .Net ==== |
| | + | |
| | + | <code vb> |
| | + | |
| | + | Imports System |
| | + | Imports System.Web |
| | + | Imports System.IO |
| | + | Imports System.Security.Cryptography |
| | + | Imports System.Text |
| | + | |
| | + | Private Sub mySoapCall() |
| | + | |
| | + | Dim token As usaepay.ueSecurityToken |
| | + | Dim hash As usaepay.ueHash = New usaepay.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 usaepay.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 |
| | + | </code> |
| | + | |
| | + | ==== .NET C# ==== |
| | + | <code c> |
| | + | usaepay.ueSecurityToken token = new usaepay.ueSecurityToken(); |
| | + | |
| | + | // SourceKey and Pin (created in merchant console) |
| | + | token.SourceKey = "O79****************************c8"; |
| | + | |
| | + | string pin = "1234"; |
| | + | |
| | + | // IP address of end user (if applicable) |
| | + | token.ClientIP = "11.22.33.44"; |
| | + | |
| | + | // Instantiate Hash |
| | + | usaepay.ueHash hash = new usaepay.ueHash(); |
| | + | hash.Type = "md5"; // Type of encryption |
| | + | hash.Seed = Guid.NewGuid().ToString(); // unique encryption seed |
| | + | |
| | + | // Assemble string and hash |
| | + | string prehashvalue = string.Concat(token.SourceKey, hash.Seed, pin); |
| | + | hash.HashValue = GenerateHash(prehashvalue); |
| | + | |
| | + | // Add hash to token |
| | + | token.PinHash = hash; |
| | + | |
| | + | </code> |
| | + | |
| | + | ==== Coldfusion ==== |
| | + | |
| | + | NOTE: this example has not been tested and is provided as is. |
| | + | |
| | + | <code coldfusion> |
| | + | <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> |
| | + | </code> |
| | + | |
| | + | ===== Change History ===== |
| | + | |
| | + | ^ Version ^ Change ^ |
| | + | | [[developer:soap-1.1:objects:uesecuritytoken|1.1]] | Method added prior to soap-1.1 | |