closeBatch

Close a batch specified by BatchRefNum.

Description

This method will close or settle an open batch. Upon settlement the funds will be transferred to the merchant's bank account.

To check the status of a batch and determine whether it has already been settled, is still open, or awaiting settlement, use the getBatchStatus method.

See also getBatchStatus, searchBatches, getBatchTransactions

Syntax

boolean closeBatch ( ueSecurityToken Token, string BatchRefNum )

Arguments

Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and validate transaction.
string BatchRefNum A unique batch reference number assigned by the gateway.

Return Value

Type Description
boolean Returns confirmation of the close batch request only if successful. If request fails, an exception will be thrown.

Examples

PHP

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

    try {

      // To close a specific batch use the gateway assigned batchrefnum:
      $batchrefnum='1234567';

      // To close the current batch use '0':
      $batchrefnum='0';

      $res=$client->closeBatch($token,$batchrefnum);

    }

    catch(SoapFault $e) {

      echo $e->getMessage();
      echo "\n\nRequest: " . $client->__getLastRequest();
      echo "\n\nResponse: " . $client->__getLastResponse();

    }

.NET VB


            Try
                client.closeBatch(token, "0")
                MsgBox("Your batch has closed.")
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

C Sharp (.Net)

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

    Boolean result;

    // close current batch
    try
    {
        result = client.closeBatch(token, "0");

        if (result) MessageBox.Show("Batch closed successfully");
        else MessageBox.Show("Batch failed to close");
    }
    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:closeBatch>
    <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">3add5373db23ce3407500635de721d83a7c900b9</HashValue>
    <Seed xsi:type="xsd:string">11177496803-test</Seed>
    <Type xsi:type="xsd:string">sha1</Type>
    </PinHash>
    <SourceKey xsi:type="xsd:string">_B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
    </Token>
    <BatchRefNum xsi:type="xsd:string">201943</BatchRefNum>
    </ns1:closeBatch>
    </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: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:closeBatchResponse>
    <closeBatchReturn xsi:type="xsd:boolean">true</closeBatchReturn>
    </ns1:closeBatchResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

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 {

    //Creating Close Batch Request object
    CloseBatchRequest Request = new CloseBatchRequest();

    Request.setToken(token);

    //Setting batchRefNum to 0 for current batch, for a different batch set to the Batch Ref Num
    Request.setBatchRefNum(BigInteger.ZERO);

    CloseBatchResponse Result = client.closeBatch(Request);

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

Change Log

Version Change
1.7 Changed BatchRefNum to type string