developer:soap-1.6:methods:searchproducts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:soap-1.6:methods:searchproducts [2012/08/04 11:23] (current)
tem created
Line 1: Line 1:
 +<embed ..:​contents/>​
  
 +====== searchProducts ======
 +
 +Search products and return full product records.
 +
 +===== Description =====
 +
 +TBD.
 +
 +The following fields may be used to search the database and return transaction details: ​
 +
 +  * ProductID ​
 +  * ProductRefNum ​
 +  * SKU 
 +  * CategoryID ​
 +  * Enabled ​
 +  * Name 
 +  * Description ​
 +  * Model 
 +  * Weight ​
 +  * ShipWeight ​
 +  * Price 
 +  * WholesalePrice ​
 +  * ListPrice ​
 +  * DateAvailable ​
 +  * Manufacturer ​
 +  * Type 
 +  * MinQuantity ​
 +  * MaxQuantity ​
 +  * ImageURL ​
 +  * URL
 +
 +See also [[searchProductsCustom]] and [[searchProductsCount]]
 +
 +
 +===== Syntax =====
 +
 +[[..:​objects:​ProductSearchResult]] **searchProducts** ( [[..:​objects:​ueSecurityToken]] Token, [[..:​objects:​SearchParam]] Search, boolean MatchAll, integer Start, integer Limit, string Sort)
 +
 +
 +
 +===== Arguments =====
 +
 +^Type   ​^Name ​  ​^Description ​  ^
 +|[[..:​objects:​ueSecurityToken]] |Token |Merchant security token: used to identify merchant and validate transaction.|
 +|[[..:​objects:​SearchParam]] |Search |Array of search parameters (ProductSearchParam objects) available.|
 +|boolean |MatchAll |If set to "​true,"​ only results matching all search criteria will be returned, if set to "​false,"​ results matching any of the search criteria will be returned.|
 +|integer |Start |Record number to start returning from (ie if 1,000 were found and you only want to receive the last 200 you would set Start=800 and Limit=200) |
 +|integer |Limit |Maximum number of transactions to return in result set. |
 +|string |Sort |Comma separated list of fields to sort by. |
 +
 +
 +===== Return Value =====
 +
 +|[[..:​objects:​ProductSearchResult]] |Returns full product records for all products matching the specified search parameters. |
 +
 +===== Examples =====
 +
 +
 +
 +
 +==== PHP 5 ====
 +For directions on how to set up the WSDL link, create "​$token"​ and "​$client",​ go to [[developer:​soap:​howto:​php|PHP Soap How-to]].
 +
 +<code php>
 +
 +<?​php ​
 +
 +try { 
 +
 +  // Create search parameter list 
 +  $search=array( ​
 +    array( ​
 +      '​Field'​=>'​name', ​  
 +      '​Type'​=>'​eq', ​
 +      '​Value'​=>'​A Great Product'​)
 +    ); 
 +  $start=0; ​
 +  $limit=100; ​
 +  $matchall=true; ​
 +  $sort='​created';​
 +
 +  $res=$client->​searchProducts($token,​$search,​$matchall,​$start,​$limit,​$sort); ​
 +
 +  print_r($res); ​
 +             
 +
 +catch(SoapFault $e) { 
 +  echo $client->​__getLastResponse(); ​
 +  die("​Search Products Failed :"​.$e->​getMessage()); ​
 +
 +
 +?> 
 +</​code>​
 +
 +==== PHP 4 (NuSOAP) ====
 +
 +<code php>
 +<?​php ​
 +
 +include '​./​nusoap.php'; ​
 +
 +// Create Soap Client ​
 +$s=new soapclient("​./​usaepay.wsdl",'​wsdl'​); ​
 +$tran=$s->​getProxy(); ​
 +
 +// Source Key Setting ​
 +$sourcekey='​yQbOFkjD8wwlkZ3AhY248k3Lc9PH1l14'; ​
 +$pin='​1234'; ​
 +
 +// Prep source key 
 +$seed=mktime() . rand(); ​
 +$tmp=$sourcekey . $seed . $pin; 
 +$hash=sha1($tmp); ​
 +$token=array('​SourceKey'​=>​$sourcekey,​ '​PinHash'​=>​array('​Type'​=>'​sha1',​ '​Seed'​=>​$seed,'​HashValue'​=>​$hash)); ​
 +
 +
 +// Prep Request data 
 +$search=array( ​
 +      array('​Field'​=>'​title',​ '​Type'​=>'​eq','​Value'​=>'​A Great Product'​)
 +); 
 +$start=0; ​
 +$limit=10; ​
 +$matchall=true; ​
 +$sort='​created';​
 +
 +$res=$tran->​searchProducts($token,​$search,​$matchall,​$start,​$limit,​$sort); ​
 +
 +if(!$err=$tran->​getError()) { 
 +        print_r($res); ​
 +} else { 
 +
 +        echo "​Error:​ $err\n"; ​
 +        echo $tran->​request;  ​
 +
 +
 +</​code>​
 +
 +==== VB ====
 +<code vb>
 +Dim MatchAll As Boolean
 +        MatchAll = False
 +        Dim searchParams(1) As usaepay.SearchParam
 +        searchParams(0) = New usaepay.SearchParam
 +        searchParams(0).Field = "​Created"​
 +        searchParams(0).Type = "​gt"​
 +        searchParams(0).Value = "​2010-09-07"​
 +
 +        Dim SearchResults As usaepay.ProductSearchResult = New usaepay.ProductSearchResult
 +        SearchResults = client.searchProducts(token,​ searchParams,​ MatchAll, "​0",​ "​1000",​ "​created"​)
 +
 +        MsgBox(SearchResults.ProductsMatched)
 +</​code>​
 +
 +==== .NET C# ====
 +<code c>
 +            usaepay.SearchParam[] param = new usaepay.SearchParam[1];​
 +            param[0] = new usaepay.SearchParam();​
 +            param[0].Field = "​Created";​
 +            param[0].Type = "​Contains";​
 +            param[0].Value = "​2010-08-12";​
 +
 +            Boolean matchAll = true;
 +            string start = "​0";​
 +            string limit = "​10";​
 +            string sort = "​created";​
 +
 +            usaepay.ProductSearchResult response = new usaepay.ProductSearchResult();​
 +
 +            try
 +            {
 +                response = client.searchProducts(token,​ param, matchAll, start, limit, sort);
 +                MessageBox.Show(string.Concat(response.ProductsMatched));​
 +            }
 +            catch (Exception err)
 +            {
 +                MessageBox.Show(err.Message);​
 +            }
 +</​code>​
 +
 +==== Coldfusion ====
 +
 +//NOTE//: this example has not been tested and is provided as is 
 +
 +<code cfm>
 +<​cfscript> ​
 +Start = 0; 
 +Limit = 10; 
 +MatchAll=1; ​
 +Sort='​created';​
 +Search=ArrayNew(1); ​
 +Search[1]=structnew(); ​
 +Search[1].Field='​created'; ​
 +Search[1].Type='​gt'; ​
 +Search[1].Value='​2006-09-01'; ​
 +
 +ws = createObject("​webservice",​ "​https://​www.usaepay.com/​soap/​gate/​3213EA2A/​usaepay.wsdl"​); ​
 +Output = ws.searchTransactions(Token,​ Search, MatchAll, Start, Limit, Sort); ​
 +</​cfscript> ​
 +</​code>​
 +==== XML ====
 +
 +<code xml>
 +<?xml version="​1.0"​ encoding="​UTF-8"?> ​
 +<​SOAP-ENV:​Envelope xmlns:​SOAP-ENV="​http://​schemas.xmlsoap.org/​soap/​envelope/" ​
 +xmlns:​ns1="​urn:​usaepay"​ xmlns:​xsd="​http://​www.w3.org/​2001/​XMLSchema" ​
 +xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance" ​
 +xmlns:​SOAP-ENC="​http://​schemas.xmlsoap.org/​soap/​encoding/" ​
 +SOAP-ENV:​encodingStyle="​http://​schemas.xmlsoap.org/​soap/​encoding/"> ​
 +<​SOAP-ENV:​Body> ​
 +<​ns1:​searchTransactions> ​
 +<Token xsi:​type="​ns1:​ueSecurityToken">​
 +<​ClientIP xsi:​type="​xsd:​string">​192.168.0.1</​ClientIP>​
 +<PinHash xsi:​type="​ns1:​ueHash">​
 +<​HashValue xsi:​type="​xsd:​string">​11ac55b0a0b59f8f028dbf85bc32266fa973dd0e</​HashValue>​
 +<Seed xsi:​type="​xsd:​string">​12678150211876663375</​Seed>​
 +<Type xsi:​type="​xsd:​string">​sha1</​Type>​
 +</​PinHash>​
 +<​SourceKey xsi:​type="​xsd:​string">​HB4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</​SourceKey>​
 +</​Token>​
 +<Search SOAP-ENC:​arrayType="​ns1:​SearchParam[1]"​ xsi:​type="​ns1:​SearchParamArray"> ​
 +<item xsi:​type="​ns1:​SearchParam"> ​
 +<Field xsi:​type="​xsd:​string">​amount</​Field> ​
 +<Type xsi:​type="​xsd:​string">​eq</​Type> ​
 +<Value xsi:​type="​xsd:​string">​29.00</​Value> ​
 +</​item> ​
 +</​Search> ​
 +<​MatchAll xsi:​type="​xsd:​boolean">​true</​MatchAll> ​
 +<Start xsi:​type="​xsd:​integer">​0</​Start> ​
 +<Limit xsi:​type="​xsd:​integer">​10</​Limit> ​
 +<Sort xsi:​type="​xsd:​string">​created</​Sort> ​
 +</​ns1:​searchTransactions> ​
 +</​SOAP-ENV:​Body> ​
 +</​SOAP-ENV:​Envelope>​
 +</​code>​
 +
 +
 +
 +===== Change History =====
 +
 +^Version ^Change ^
 +|[[developer:​soap-1.3:​methods:​searchproducts|1.3]] | Added method |
developer/soap-1.6/methods/searchproducts.txt ยท Last modified: 2012/08/04 11:23 by tem

Page Tools