searchCustomersCustom
Search for customers, return custom result set.
Description
This method allows you to search the customer database using flexible search terms. This method searches the customer database (aka recurring billing) not the transactions history. To search the transaction history for a specific customer, use either the searchTransactions or getCustomerHistory method.
Use as many or as few search terms as you like. With MatchAll set to "true," all terms must match to return a result. If the search does not yield the desired results, try broadening your search by eliminating terms, or change MatchAll to "false."
Valid field names for search, sort and return are:
- BillingAddress.FirstName
- BillingAddress.lastname
- BillingAddress.Company
- BillingAddress.Street
- BillingAddress.Street2
- BillingAddress.City
- BillingAddress.State
- BillingAddress.Zip
- BillingAddress.Country
- BillingAddress.Phone
- BillingAddress.Fax
- BillingAddress.Email
- Amount
- CustNum
- CustomerID
- Created
- Description
- Enabled
- Failures
- Modified
- Start
- Next
- Notes
- NumLeft
- OrderID
- ReceiptNote
- Schedule (1=Daily,2=Weekly,3=Bi-Weekly,4=Monthly,5=Bi-Monthly,6=Quarterly,7=Bi-Annually,8=Annually,9=First of Month, 10=Last Day of Month)
- SendReceipt
- Source
- Tax
- User
- CustomFields (custom1, custom2, custom3, etc)
See also searchcustomers, searchcustomerscount, searchCustomerID
Syntax
string searchCustomersCustom ( 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. |
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 | Start position, defaults to 0 (first customer found). |
integer | Limit | Maximum number of customers to return in result. |
string | FieldList | String Array of fields to return in search. |
string | Format | Specify format of return data. Possible formats include: csv, tab, xml, php, json |
string | Sort | Field name to sort the results by |
Return Value
Type | Description |
---|---|
string | Base64 encode result set. Returns all of the fields from any customers matching your search parameters. |
Example
PHP
For directions on how to set up the WSDL link, create "$token" and "$client", go to PHP Soap How-to.
<?php
try {
$search=array(
array('Field'=>'amount', 'Type'=>'gt','Value'=>'8.00'),
array('Field'=>'customerid', 'Type'=>'gt', 'Value'=>'0')
);
$start=0;
$limit=10;
$matchall=true;
$fieldList = array('CustNum', 'BillingAddress.Company', 'Amount', 'Next');
$format='csv';
$Sort='fname';
$res=$this->client->searchCustomersCustom($this->token,$search,$matchall,$start,$limit,$fieldList,$format,$Sort);
$res=base64_decode($res);
print_r($res);
}
catch (SoapFault $e) {
die("Search Customers failed :" .$e->getMessage());
}
?>
.NET VB
Dim matchAll As Boolean
matchAll = True
Dim search(0 To 1) As newtek.SearchParam
search(0) = New newtek.SearchParam()
search(0).Field = "Created"
search(0).Type = "Contains"
search(0).Value = "2010-09-09"
Dim FieldList(0 To 2) As String
FieldList(0) = "CustNum"
FieldList(1) = "BillingAddress.Company"
FieldList(2) = "Amount"
Dim result As String
result = client.searchCustomersCustom(token, search, matchAll, "0", "10", FieldList, "csv", "fname")
Dim binaryData() As Byte
binaryData = Convert.FromBase64String(result)
MsgBox(Encoding.UTF8.GetString(binaryData))
.NET C
For directions on how to set up the WSDL link and create the "token" and "client" variables, go to the C Sharp .Net Soap How-to.
Boolean matchAll = true;
newtek.SearchParam[] search = new newtek.SearchParam[2];
search[0] = new newtek.SearchParam();
search[0].Field = "Created";
search[0].Type = "Contains";
search[0].Value = "2010-08-10";
string[] FieldList = new string[3];
FieldList[0] = "CustNum";
FieldList[1] = "BillingAddress.Company";
FieldList[2] = "Amount";
string result;
try
{
result = client.searchCustomersCustom(token, search, matchAll, "0", "10", FieldList, "csv", "fname");
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:newtek" 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:searchCustomersCustom>
<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">6e62ffd4cbf1aaa659912f4444122e0b66ed2bd4</HashValue>
<Seed xsi:type="xsd:string">12966001102012554704</Seed>
<Type xsi:type="xsd:string">sha1</Type>
</PinHash>
<SourceKey xsi:type="xsd:string">(Your Source Key Here)</SourceKey>
</Token>
<Search SOAP-ENC:arrayType="ns1:SearchParam[2]" xsi:type="ns1:SearchParamArray">
<item xsi:type="ns1:SearchParam">
<Field xsi:type="xsd:string">amount</Field>
<Type xsi:type="xsd:string">gt</Type>
<Value xsi:type="xsd:string">8.00</Value>
</item>
<item xsi:type="ns1:SearchParam">
<Field xsi:type="xsd:string">customerid</Field>
<Type xsi:type="xsd:string">gt</Type>
<Value xsi:type="xsd:string">0</Value>
</item>
</Search>
<MatchAll xsi:type="xsd:boolean">true</MatchAll>
<Start xsi:type="xsd:integer">0</Start>
<Limit xsi:type="xsd:integer">10</Limit>
<FieldList SOAP-ENC:arrayType="xsd:string[5]" xsi:type="ns1:stringArray">
<item xsi:type="xsd:string">CustNum</item>
<item xsi:type="xsd:string">BillingAddress.Company</item>
<item xsi:type="xsd:string">Amount</item>
<item xsi:type="xsd:string">Next</item>
<item xsi:type="xsd:string">CustomData</item>
</FieldList>
<Format xsi:type="xsd:string">csv</Format>
<Sort xsi:nil="true"/></ns1:searchCustomersCustom>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Change History
Version | Change |
---|---|
1.2 | Added Sort Parameter |
1.1 | Soap 1.1 Release |
1.0 | Method added in soap v1.0 |