CloseBatch

Description

The CloseBatch method closes an open batch.

Syntax

boolean GetMerchantTransactionData(SecurityToken securityToken, string batchId)

Arguments

Type

Name

Req.

Description

SecurityToken

securityToken

R

A unique token that is used to identify a merchant and authenticate the API request.

string

batchId

R

Identifies the batch to close.

Note: Use 0 to reference the current open batch.

Return Value

TypeDescription
booleanOn success, true is returned. Otherwise, a fault is returned.

Example Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ebiz="http://eBizCharge.ServiceModel.SOAP">
  <soapenv:Header/>
  <soapenv:Body>
    <ebiz:CloseBatch>
      <ebiz:securityToken>
        <ebiz:SecurityId>*************-4621-b899-************</ebiz:SecurityId>
        <ebiz:UserId/>
        <ebiz:Password/>
      </ebiz:securityToken>
      <ebiz:batchId>0</ebiz:batchId>
    </ebiz:CloseBatch>
  </soapenv:Body>
</soapenv:Envelope>
private static void CloseBatch()
{
  IeBizService apiClient = new IeBizServiceClient();
  SecurityToken securityToken = new SecurityToken()
  {
    SecurityId = "*************-2201-4970-ba92-************",
    UserId = "",
    Password = ""
    };

  string batchId = "0";

  try
  {
    var closeBatch = apiClient.CloseBatch(securityToken, batchId);
    Console.WriteLine($"CloseBatchResult: {closeBatch}");
  }
  catch (Exception ex)
  {
    Console.WriteLine("An error occurred while closing the batch.");
    Console.WriteLine($"Error message: {ex.Message}");
  }
}
// Initialize the SOAP client (replace with your actual endpoint URL)
$client = new SoapClient("https://ebizsoapapidev1.ebizcharge.net/eBizService.svc?singleWsdl");

// Define the merchant security token
$securityToken = array(
  'SecurityId' => '*************-4970-ba92-************' // Replace with your actual token
);

// Define parameters for GetBatchTransactions
$batchId = "1"; // Not used in this example

// Prepare parameters for the SOAP request
$params = array(
  'securityToken'      => $securityToken,
  'batchId'               => $batchId
);

try {
  // Make the SOAP request
  $response = $client->CloseBatch($params);

  // Extract result object from response
  if (!isset($response->CloseBatchResult)) {
    echo "No CloseBatchResult in response.\n";
    exit;
  }

  $batchStatus = $response->CloseBatchResult;
  echo "===== CloseBatchResult =====\n";
  echo "CloseBatchResult:       " . ($batchStatus->CloseBatchResult       ?? '') . "\n";
  echo "=======================\n";

} catch (SoapFault $e) {
  echo "SOAP Error: " . $e->getMessage() . "\n";
}

Example Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <CloseBatchResponse xmlns="http://eBizCharge.ServiceModel.SOAP">
      <CloseBatchResult>true</CloseBatchResult>
    </CloseBatchResponse>
  </s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <s:Fault>
      <faultcode>s:Error</faultcode>
      <faultstring xml:lang="en-US">Error: 40027: Unable to find requested batch.</faultstring>
    </s:Fault>
  </s:Body>
</s:Envelope>