SOAP API Reference

Capture (SOAP)

 

Capture

The Capture operation is used to capture a single transaction for settlement after it has been successfully authorized by the Authorize operation.

Note: The Capture differenceData object is required when capturing a single transaction with a settlement amount different from the original authorization amount, or when ship date is required in MOTO transactions.

 

In the Capture differenceData object, the Amount parameter should be equal to the new amount being captured.

 

For example:

Authorize Amount = 10.00; Capture Amount = 10.00; Settled Amount = 10.00 Authorize Amount = 10.00; Capture Amount = 14.00 (result of +$4.00 INCAUTH); Settled Amount = 14.00 Authorize Amount = 10.00; Capture Amount = 8.00 (result of -$2.00 REVAUTH); Settled Amount = 8.00

 

Operation

Response Capture(string sessionToken, Capture differenceData, string applicationProfileId, string workflowId);

 

Parameters

Parameter Data Type Description
sessionToken String The limited-life token used to authenticate to CWS.
differenceData Capture The capture details for a single transaction.
Note: You must send in BankcardCapture for Bankcard transactions.
applicationProfileId String A token representing the PTLS Socket ID unique to each Service Key and configuration data combination. Returned by the SaveApplicationData operation.
workflowId String Identifies the workflow to use for the transaction. If not supporting custom workflows, pass the serviceId returned byGetServiceInformation.

 

Return Type

Data Type Description
Response Capture response data.
Note: For Bankcard (BCP) transactions, the response object is BankcardCaptureResponse.

 

Exceptions

CWSFault CWSInvalidOperationFault
AuthenticationFault CWSInvalidServiceInformationFault
ExpiredTokenFault CWSOperationNotSupportedFault
InvalidTokenFault CWSTransactionAlreadySettledFault
CWSConnectionFault CWSTransactionFailedFault
CWSExtendedDataNotSupportedFault CWSTransactionServiceUnavailableFault
CWSInvalidMessageFormatFault CWSValidationResultFault
For additional details about each fault, refer to Transaction Processing Faults in the CWS Developer API Reference.

 

Code Snippets

public Response Capture(string sessionToken, Capture capture, string applicationProfileId, string workflowId)
{
  using (var client = new CwsTransactionProcessingClient(ConfigurationManager.AppSettings["Bindings.TxnSoap"]))
  {
    try
    {
      return client.Capture(sessionToken, capture, applicationProfileId, workflowId);
    }
    catch (FaultException ex)
    {
      SoapFaultHandler.HandleFaultException(ex);
    }
  }
}

 

/* $transactionID is the known transaction ID of a previous transaction
 * $amount is the amount of money to charge, leave it empty to charge existing amount
 * $tip_amount is the amount of tip money to charge, leave it empty to charge existing amount*/
 
public function capture($transactionID, $creds = null, $amount = null, $tip_amount = null)
{
  if (! $this->signOn ())
    return false;
 
  $cap = new BankcardCapture ();
  $cap->TransactionId = $transactionID;
  $cap->Amount = $amount;
  $cap->TipAmount = $tip_amount;
  if ($creds != null)
  {
    $cap->Addendum = new Addendum ();
    $cap->Addendum->Unmanaged = new Unmanaged ();
    $cap->Addendum->Unmanaged->Any = new Any ();
    $cap->Addendum->Unmanaged->Any->string = $creds;
  }
 
  // Build Capture
  $trans = new CaptureAuth ();
  $trans->sessionToken = $this->session_token;
  $trans->differenceData = $cap;
  $trans->merchantProfileId = $this->merchantProfileID;
  $trans->workflowId = $this->workflowId;
  $trans->applicationProfileId = $this->appProfileID;
 
  try
  {
    $capResponse = $this->bankCard->Capture ( $trans )->CaptureResult;
    //echo ('
'.$this->bankCard->__getLastRequestHeaders());
    //echo ('
'.$this->bankCard->__getLastRequest());
    /*echo ('
'.$this->bankCard->__getLastResponseHeaders());
     echo ('
'.$this->bankCard->__getLastResponse());*/
    return $capResponse;
  }
  catch ( SoapFault $e )
  {
    echo "
REQUEST:\n" . $this->bankCard->__getLastRequest() . "\n
";
    process_soap_error ( $e );
    echo 'SERVER ERROR: Error trying to Capture.
';
    $xmlFault = $this->bankCard->__getLastResponse ();
    $errors = handleTxnFault ( $e, $xmlFault );
    echo $errors;
    exit ();
  }
}

CaptureAll

The CaptureAll operation is used to flag all transactions for settlement that have been successfully authorized using the Authorize operation. Merchants may wish to invoke this operation to ensure all transactions are included in the batch that is sent for settlement processing by the cut-off times established by the service provider or to transmit smaller batches to the service provider for settlement.

 

In addition, when performing CaptureAll on terminal capture hosts, settlement times of up to 5 minutes or more are not uncommon depending on the number of transactions in the batch. Client applications need to anticipate and account for longer settlement processing times in their time-out management schemes.

Note: The Capture differenceData object is required when capturing a single transaction with a settlement amount different from the original authorization amount or when ship date is required in MOTO transactions.

 

In the Capture differenceData object, the Amount parameter should be equal to the new amount being captured.

 

For example:

Authorize Amount = 10.00; Capture Amount = 10.00; Settled Amount = 10.00 Authorize Amount = 10.00; Capture Amount = 14.00 (result of +$4.00 INCAUTH); Settled Amount = 14.00 Authorize Amount = 10.00; Capture Amount = 8.00 (result of -$2.00 REVAUTH); Settled Amount = 8.00

 

Operation

List&lt;Response&gt; CaptureAll(string sessionToken, List&lt;Capture&gt; differenceData, List&lt;String&gt; batchIds, string applicationProfileId, <em>MerchantProfile merchantProfile</em>, string merchantProfileId, string workflowId);

 

Parameters

Parameter Data Type Description
sessionToken String The limited-life token used to authenticate to CWS.
differenceData List<Capture> A list of one or more transactions to capture.
Note: You must send in BankcardCapture for Bankcard transactions.
batchIds List<String> A list of one or more batch Ids to capture.
applicationProfileId String A token representing the PTLS Socket ID unique to each Service Key and configuration data combination. Returned by the SaveApplicationData operation.
merchantProfileId String The specific Merchant Profile Identifier to use.
workflowId String Identifies the workflow to use for the transaction. If not supporting custom workflows, pass the serviceId returned by GetServiceInformation.

 

Return Type

Data Type Description
List<Response> A collection of capture response data.
Note: For Bankcard (BCP) transactions, the response object is BankcardCaptureResponse.

 

Exceptions

CWSFault CWSInvalidOperationFault
AuthenticationFault CWSInvalidServiceInformationFault
ExpiredTokenFault CWSOperationNotSupportedFault
InvalidTokenFault CWSTransactionAlreadySettledFault
CWSConnectionFault CWSTransactionFailedFault
CWSExtendedDataNotSupportedFault CWSTransactionServiceUnavailableFault
CWSInvalidMessageFormatFault CWSValidationResultFault
For additional details about each fault, refer to Transaction Processing Faults in the CWS Developer API Reference.

 

Code Snippets

public List CaptureAll(string sessionToken, List captures, string applicationProfileId, string merchantProfileId, string workflowId, List batchIds = null)
{
  Type type = typeof(T);
 
  if (_msgFormat == MessageFormat.SOAP.ToString())
  {
    var bankcardCaptures = new List();
    var regularCaptures = new List();
    if (type == typeof(BankcardCapture))
    {
      foreach (var capture in captures)
      {
        bankcardCaptures.Add(capture as BankcardCapture);
      }
    }
    else
    {
      foreach (var capture in captures)
      {
        regularCaptures.Add(capture as Capture);
      }
    }
  using (var client = new CwsTransactionProcessingClient(ConfigurationManager.AppSettings["Bindings.TxnSoap"]))
  {
    try
    {
      if(bankcardCaptures.Count &amp;gt; 0 &amp;amp;&amp;amp; batchIds != null)
        return client.CaptureAll(sessionToken, bankcardCaptures.ToArray(), batchIds.ToArray(), applicationProfileId, merchantProfileId, workflowId).ToList();
      if(bankcardCaptures.Count &amp;gt; 0)
        return client.CaptureAll(sessionToken, bankcardCaptures.ToArray(), null, applicationProfileId, merchantProfileId, workflowId).ToList();
      if(batchIds != null)
        return client.CaptureAll(sessionToken, regularCaptures.ToArray(), batchIds.ToArray(), applicationProfileId, merchantProfileId, workflowId).ToList();
      return client.CaptureAll(sessionToken, regularCaptures.ToArray(), null, applicationProfileId, merchantProfileId, workflowId).ToList();
    }
    catch (FaultException ex)
    {
      SoapFaultHandler.HandleFaultException(ex);
    }
  }
}

 

/* $differenceData is an object that contains any data to adjust at the time of settlement */
 
public function captureAll($differenceData, $creds = null)
{
  if (! $this-&amp;gt;signOn ())
    return false;
 
  if ($this-&amp;gt;svc instanceof BankcardService)
  {
    $diffDataArray = array ();
    $caDiffData = new CaptureDifferenceData ();
 
    if ($differenceData != null)
    {
      $i = 0;
      if (is_array ( $differenceData ))
      {
        foreach ( $diffData as $differenceData )
        {
          $caDiffData-&amp;gt;TransactionId = $diffData-&amp;gt;transactionID;
          $caDiffData-&amp;gt;Amount = $diffData-&amp;gt;amount;
          $caDiffData-&amp;amp;gt;TipAmount = $diffData-&amp;gt;tip_amount;
          $caDiffData-&amp;gt;ShipDate = $diffData-&amp;gt;shipDate;
          $diffDataArray [] = $caDiffData;
        }
      }
      else
      {
        $caDiffData-&amp;gt;TransactionId = $diffData-&amp;gt;transactionID;
        $caDiffData-&amp;gt;Amount = $diffData-&amp;gt;amount;
        $caDiffData-&amp;gt;TipAmount = $diffData-&amp;gt;tip_amount;
        $caDiffData-&amp;gt;ShipDate = $diffData-&amp;gt;shipDate;
        $diffDataArray [] = $caDiffData;
      }
      if ($creds != null)
      {
        $diffDataArray [0]-&amp;gt;Addendum = new Addendum ();
        $diffDataArray [0]-&amp;gt;Addendum-&amp;gt;Unmanaged = new Unmanaged ();
        $diffDataArray [0]-&amp;gt;Addendum-&amp;gt;Unmanaged-&amp;gt;Any = new Any ();
        $diffDataArray [0]-&amp;gt;Addendum-&amp;gt;Unmanaged-&amp;gt;Any-&amp;gt;string = $creds;
      }
    }
  }
 
  if ($creds != null)
  {
    $diffDataArray = array ();
    $caDiffData = new CaptureDifferenceData ();
    $caDiffData-&amp;gt;TransactionId = '-1';
    $diffDataArray [] = $caDiffData;
    $diffDataArray [0]-&amp;gt;Addendum = new Addendum ();
    $diffDataArray [0]-&amp;gt;Addendum-&amp;gt;Unmanaged = new Unmanaged ();
    $diffDataArray [0]-&amp;gt;Addendum-&amp;gt;Unmanaged-&amp;gt;Any = new Any ();
    $diffDataArray [0]-&amp;gt;Addendum-&amp;gt;Unmanaged-&amp;gt;Any-&amp;gt;string = $creds;
  }
 
  // Build Capture
  $trans = new CaptureAll ();
  $trans-&amp;gt;sessionToken = $this-&amp;gt;session_token;
  $trans-&amp;gt;differenceData = $diffDataArray;
  $trans-&amp;gt;merchantProfileId = $this-&amp;gt;merchantProfileID;
  $trans-&amp;gt;workflowId = $this-&amp;gt;workflowId;
  $trans-&amp;gt;applicationProfileId = $this-&amp;gt;appProfileID;
 
  try
  {
    $capAllResponse = $this-&amp;gt;bankCard-&amp;gt;CaptureAll ( $trans )-&amp;gt;CaptureAllResult;
    //echo ('
'.$this-&amp;gt;bankCard-&amp;gt;__getLastRequestHeaders());
    //echo ('
'.$this-&amp;gt;bankCard-&amp;gt;__getLastRequest());
    //echo ('
'.$this-&amp;gt;bankCard-&amp;gt;__getLastResponseHeaders());
    //echo ('
\n'.$this-&amp;gt;bankCard-&amp;gt;__getLastResponse().'\n');
    return $capAllResponse;
  }
  catch ( SoapFault $e )
  {
    /*echo "
REQUEST:\n" . $this-&amp;gt;bankCard-&amp;gt;__getLastRequest() . "\n
";*/
    //process_soap_error ( $e );
    echo 'SERVER ERROR: Error trying to Capture.
';
    echo ('
'.$this-&amp;gt;bankCard-&amp;gt;__getLastRequest());
    $xmlFault = $this-&amp;gt;bankCard-&amp;gt;__getLastResponse ();
    $errors = handleTxnFault ( $e, $xmlFault );
    echo $errors;
    exit ();
  }
}