searchBatches

Search previously settled batches.

Description

Use this method to search batches that you have already settled. This method allows the following fields to be used in the search: - Sequence - Platform reference number. - Opened - Date batch was opened. - Closed - Date batch was closed.

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 result, try broadening your search by eliminating terms, or change MatchAll to "false."

See also getBatchStatus, closeBatch, getBatchTransactions

Syntax

BatchSearchResult searchBatches ( ueSecurityToken Token, SearchParam Search, boolean MatchAll, integer Start, integer Limit, 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 Index to start returning batches from.
integer Limit Max number of batches to return in result set.
string Sort Field name to sort the results by

Return Value

Name Description
BatchSearchResult Returns the result of the batch search based on the search parameters set.

Examples

PHP

For directions on how to set up the WSDL link, create "$token" and "$client", go to PHP Soap How-to.

    <?php

    try {

    // make sure you have prepared data to search on

      $search=array(
        array(
          'Field'=>'closed',
          'Type'=>'gt',
          'Value'=>'2007-04-01'),
        );
      $start=0;
      $limit=100;
      $matchall=true;
      $sort='closed';

      $res=$client->searchBatches($token,$search,$matchall,$start,$limit,$sort);

      print_r($res);
    }

    catch (SoapFault $e) {

      echo $client->__getLastRequest();
      echo $client->__getLastResponse();
      die("Search batches failed failed :" .$e->getMessage());

    }

    ?>

Java

This example uses the Newtek Gateway Java library. For directions on how to install the library and create the token/client objects, go to the Java JAX-WS Howto.

    try {

    SearchParamArray searchParams = new SearchParamArray();
    searchParams.add(new SearchParam("Sequence","eq", "123456"));
    BigInteger start = new BigInteger("0");
    BigInteger limit = new BigInteger("9999999");


    BatchSearchResult BatchResult = new BatchSearchResult();
    BatchResult = client.searchBatches(token, searchParams, true, start, limit, "Sequence");


      System.out.println(BatchResult.getBatchesMatched());
    } catch (Exception e) {
        System.out.println("Soap Exception: " + e.getMessage());
    }

.NET VB

    Dim matchAll As Boolean
            matchAll = True
            Dim start As String
            Dim limit As String
            Dim sort As String
            start = "0"
            limit = "10"
            sort = "closed"

            Dim search(0 To 1) As newtek.SearchParam
            search(0) = New newtek.SearchParam
            search(0).Field = "closed"
            search(0).Type = "gt"
            search(0).Value = "2010-08-05"

            Dim result As newtek.BatchSearchResult = New newtek.BatchSearchResult
            result = client.searchBatches(token, search, matchAll, start, limit, sort)
            MsgBox(result.BatchesMatched)

.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;
                matchAll = true;
                string start = "0";
                string limit = "10";
                string sort = "closed";

                newtek.SearchParam[] search = new newtek.SearchParam[2];
                search[0] = new newtek.SearchParam();

                search[0].Field = "Closed";
                search[0].Type = "gt";
                search[0].Value = "2010-08-05";

                newtek.BatchSearchResult result = new newtek.BatchSearchResult();

                try
                {
                    result = client.searchBatches(token, search, matchAll, start, limit, sort);

                    MessageBox.Show(string.Concat(result.BatchesMatched));

                }


                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }

XML

Request:

    <?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:searchBatches>
    <Token xsi:type="ns1:ueSecurityToken">
    <ClientIP xsi:type="xsd:string">123.123.123.123</ClientIP>
    <PinHash xsi:type="ns1:ueHash">
    <HashValue xsi:type="xsd:string">e64020497009e46cec2da75a7b92d749df748521</HashValue>
    <Seed xsi:type="xsd:string">1278362198-test</Seed>
    <Type xsi:type="xsd:string">sha1</Type>
    </PinHash>
    <SourceKey xsi:type="xsd:string">_B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
    </Token>
    <Search SOAP-ENC:arrayType="ns1:SearchParam[1]" xsi:type="ns1:SearchParamArray">
    <item xsi:type="ns1:SearchParam">
    <Field xsi:type="xsd:string">BatchRefNum</Field>
    <Type xsi:type="xsd:string">eq</Type>
    <Value xsi:type="xsd:string">198907</Value>
    </item>
    </Search>
    <MatchAll xsi:type="xsd:boolean">true</MatchAll>
    <Start xsi:type="xsd:integer">0</Start>
    <Limit xsi:type="xsd:integer">100</Limit>
    <Sort xsi:type="xsd:string">closed</Sort>
    </ns1:searchBatches>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

Response:

    <?xml version="1.0" encoding="utf-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns1="urn:newtek"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
    <ns1:searchBatchesResponse>
    <searchBatchesReturn xsi:type="ns1:BatchSearchResult">
    <Batches SOAP-ENC:arrayType="ns1:BatchStatus[1]" xsi:type="ns1:BatchStatusArray">
    <item xsi:type="ns1:BatchStatus">
    <BatchRefNum xsi:type="xsd:string">198907</BatchRefNum>
    <Closed xsi:type="xsd:string">01/26/2016T11:45:33</Closed>
    <CreditsAmount xsi:type="xsd:double">3</CreditsAmount>
    <CreditsCount xsi:type="xsd:integer">1</CreditsCount>
    <NetAmount xsi:type="xsd:double">4766.17</NetAmount>
    <Opened xsi:type="xsd:string">12/02/2015T11:48:43</Opened>
    <SalesAmount xsi:type="xsd:double">4769.17</SalesAmount>
    <SalesCount xsi:type="xsd:integer">87</SalesCount>
    <Scheduled xsi:type="xsd:string"></Scheduled>
    <Sequence xsi:type="xsd:integer">2611</Sequence>
    <Status xsi:type="xsd:string">Closed</Status>
    <TransactionCount xsi:type="xsd:integer">88</TransactionCount>
    <VoidsAmount xsi:type="xsd:double">0</VoidsAmount>
    <VoidsCount xsi:type="xsd:integer">0</VoidsCount>
    </item>
    </Batches>
    <BatchesMatched xsi:type="xsd:integer">1</BatchesMatched>
    <BatchesReturned xsi:type="xsd:integer">1</BatchesReturned>
    <Limit xsi:type="xsd:integer">100</Limit>
    <StartIndex xsi:type="xsd:integer">0</StartIndex>
    </searchBatchesReturn>
    </ns1:searchBatchesResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>