searchProductsCustom

Parent Previous Next

searchProductsCustom

Search products and return specific fields in csv, tab or xml format.

 

Description

Like searchProducts this function allows for the searching of the product database. Instead of return all data about each product in Product object form, it takes a FieldList parameter which specifies which fields should be returned. The results can be returned in a csv, tab or xml format. In all cases the data is base64 encoded. Developer must decode the data before using.

The following fields may be used to search the database and return transaction details:

 

Syntax

ProductSearchResult searchProducts ( ueSecurityToken Token, SearchParam Search, boolean MatchAll, integer Start, integer Limit, string[] FieldList, string Format, string Sort)

 

Arguments

Type

Name

Description

ueSecurityToken

Token

Merchant security token: used to identify merchant and validate transaction.

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 product to return in result set.

string

FieldList

String Array of fields to return in search.

string

Format

Specify format of return data. Possible formats include: csv, tab, xml.

string

Sort

Comma separated list of fields to sort by.

 

Return Value

string

Base64 encode result set. Returns all of the fields from any transactions matching your search parameters.

 

Examples

 

PHP 5

 

<?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());

}

?>

 

 

PHP 4 (NuSOAP)

<?php

include './nusoap.php';

// Create Soap Client

$s=new soapclient("./eBizCharge.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;  

}

 

VB

 Dim search(0 To 1) As eBizCharge.SearchParam

       search(0) = New eBizCharge.SearchParam()

       search(0).Field = "Created"

       search(0).Type = "Contains"

       search(0).Value = "2010-09-07"

       Dim matchAll As Boolean

       matchAll = True

       Dim start As String

       start = "0"

       Dim limit As String

       limit = "10"

       Dim FieldList(0 To 2) As String

       FieldList(0) = "ProductRefNum"

       FieldList(1) = "Name"

       FieldList(2) = "Price"

       Dim format As String

       format = "csv"

       Dim sort As String

       sort = "created"

       Dim result As String

       result = client.searchProductsCustom(token, search, matchAll, start, limit, FieldList, format, sort)

       Dim binaryData() As Byte

       binaryData = Convert.FromBase64String(result)

       MsgBox(Encoding.UTF8.GetString(binaryData))

 

 

Coldfusion

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

<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://secure.eBizCharge.com/soap/gate/3213EA2A/eBizCharge.wsdl");

Output = ws.searchTransactions(Token, Search, MatchAll, Start, Limit, Sort);

</cfscript>

 

 

.NET C#

           eBizCharge.SearchParam[] search = new eBizCharge.SearchParam[1];

           search[0] = new eBizCharge.SearchParam();

           search[0].Field = "Created";

           search[0].Type = "Contains";

           search[0].Value = "2010-08-12";

           Boolean matchAll = true;

           string start = "0";

           string limit = "10";

           string[] FieldList = new string[3];

           FieldList[0] = "ProductRefNum";

           FieldList[1] = "Name";

           FieldList[2] = "Price";

           string format = "csv";

           string sort = "created";

           string result;

           try

           {

               result = client.searchProductsCustom(token, search, matchAll, start, limit, FieldList, format, sort);

               Byte[] binaryData = new Byte[3];

               binaryData = Convert.FromBase64String(result);

               MessageBox.Show(Encoding.UTF8.GetString(binaryData));

           }

           catch (Exception err)

           {

               MessageBox.Show(err.Message);

           }

 

 

XML

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:ns1="urn:eBizCharge" 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">34108e1b91894ab1da5ecdc213341c6d757217c1</HashValue>

<Seed xsi:type="xsd:string">11936961311067412713</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>

: