captureTransaction
Capture a queued transaction.
Description
Move an authorized transaction into the current batch for settlement. It is possible to capture an amount other than the one originally authorized, however, you must follow the guidelines established by the merchant service bank. Capturing a higher or lower dollar amount could result in additional penalties and fees.
Most banks typically allow no more than 10 days to pass between the authorization/capture and settlement of a transaction.
If you do not wish to capture a previously authorized transaction, you may void the original authorization rather than capturing a 0 dollar amount, or simply allow the captured transaction to time out.
See also runTransaction, runQuickSale, voidTransaction, runCredit, runSale, runAuthOnly, getTransactionStatus
Syntax
TransactionResponse captureTransaction ( uesecuritytoken Token, string RefNum, double Amount, string IfAuthExpired )
Arguments
Type | Name | Description |
---|---|---|
ueSecurityToken | Token | Merchant security token: used to identify merchant and validate transaction. |
string | RefNum | Unique transaction reference number assigned by the gateway. You can also use TransKey in the RefNum field. |
double | Amount | Capture Amount if different from authorization |
string | IfAuthExpired | Controls what will happen if the authorization has expired. Options are "Error" which will block the capture request; "ReAuth" which will attempt to reauthorize the funds; "Capture" which will ignore the authorization date and proceed with capture. If left blank, "Capture" will be assumed. The amount of time between an authorization expires is controlled by the "Expire Auths After" setting in the merchant console. |
Return Value
Type | Description |
---|---|
TransactionResponse | Returns a TransactionResponse object containing the results of the transaction and all relevant data. |
Examples
PHP
For directions on how to set up the WSDL link, create "$token" and "$client", go to SOAP PHP How-to.
<?php
try {
//Initial Authorization
$Request=array(
'AccountHolder' => 'Tester Jones',
'Command' => 'authonly',
'Details' => array(
'Description' => 'Example Transaction',
'Amount' => '4.00',
'Invoice' => '44539'
),
'CreditCardData' => array(
'CardNumber' => '4444555566667779',
'CardExpiration' => '0919',
'AvsStreet' => '1234 Main Street',
'AvsZip' => '99281',
'CardCode' => '999'
)
);
$amount='4.00';
$temp=$client->runTransaction($token, $Request);
//Capturing the authorization
$IfAuthExpired = 'ReAuth';
$res=$client->captureTransaction($token,$temp->RefNum,$amount, $IfAuthExpired);
}
catch (SoapFault $e) {
echo $client->__getLastRequest();
echo $client->__getLastResponse();
die("Capture Transaction failed :" .$e->getMessage());
}
?>
VB
For directions on how to set up the WSDL link and create the "token" and "client" variables, go to the Visual Basic .Net Soap How-to.
Dim client As newtek.newtekService = New newtek.newtekService
Dim token As newtek.ueSecurityToken
token = Me.CreateToken("714SSUxv1uohng2XkMJ7kLpETsu58G66", "1234")
Dim transaction As newtek.TransactionRequestObject = New newtek.TransactionRequestObject
transaction.Details = New newtek.TransactionDetail
transaction.Details.Amount = "11.11"
transaction.Details.AmountSpecified = "true"
transaction.Details.Invoice = "123456"
transaction.AuthCode = "009915"
transaction.RefNum = "46993455"
Dim response As newtek.TransactionResponse = New newtek.TransactionResponse
response = client.captureTransaction(token, transaction.RefNum, transaction.Details.Amount)
If response.ResultCode = "A" Then
MsgBox("Transaction Approved, Refnum: " & response.RefNum)
Else
MsgBox("Transaction Error, Reason: " & response.Error)
End If
.NET C
newtek.TransactionRequestObject tran = new newtek.TransactionRequestObject();
tran.Details = new newtek.TransactionDetail();
tran.Details.Amount = 1.00;
tran.Details.AmountSpecified = true;
tran.Details.Invoice = "123456";
tran.RefNum = "47001545";
newtek.TransactionResponse response = new newtek.TransactionResponse();
try
{
response = client.captureTransaction(token, tran.RefNum, tran.Details.Amount);
if (response.ResultCode == "A")
{
MessageBox.Show(string.Concat("Transaction Approved, RefNum: ",
response.RefNum));
}
else
{
MessageBox.Show(string.Concat("Transaction Failed: ",
response.Error));
}
}
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:captureTransaction>
<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">c420eb2f0a410bd1baab227b43c84b3ba7dad5ae</HashValue>
<Seed xsi:type="xsd:string">11367276629-test</Seed>
<Type xsi:type="xsd:string">sha1</Type>
</PinHash>
<SourceKey xsi:type="xsd:string">_B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
</Token>
<RefNum xsi:type="xsd:sting">1nfmkr4rsmtxhm5</RefNum>
<Amount xsi:type="xsd:double">0</Amount>
</ns1:captureTransaction>
</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:captureTransactionResponse>
<captureTransactionReturn xsi:type="ns1:TransactionResponse">
<AcsUrl xsi:type="xsd:string"></AcsUrl>
<AuthAmount xsi:type="xsd:double">0</AuthAmount>
<AuthCode xsi:type="xsd:string">066952</AuthCode>
<AvsResult xsi:type="xsd:string">No AVS response(Typically no AVS data sent or swiped transaction)
</AvsResult>
<AvsResultCode xsi:type="xsd:string"></AvsResultCode>
<BatchNum xsi:type="xsd:string">0</BatchNum>
<BatchRefNum xsi:type="xsd:string">0</BatchRefNum>
<CardCodeResult xsi:type="xsd:string">No CVV2/CVC data available for transaction.</CardCodeResult>
<CardCodeResultCode xsi:type="xsd:string"></CardCodeResultCode>
<CardLevelResult xsi:type="xsd:string">Unknown Code</CardLevelResult>
<CardLevelResultCode xsi:type="xsd:string"></CardLevelResultCode>
<ConversionRate xsi:type="xsd:double">0</ConversionRate>
<ConvertedAmount xsi:type="xsd:double">0</ConvertedAmount>
<ConvertedAmountCurrency xsi:type="xsd:string">840</ConvertedAmountCurrency>
<CustNum xsi:type="xsd:string">0</CustNum>
<Error xsi:type="xsd:string">Approved</Error>
<ErrorCode xsi:type="xsd:integer">0</ErrorCode>
<isDuplicate xsi:type="xsd:boolean">false</isDuplicate>
<Payload xsi:type="xsd:string"></Payload>
<RefNum xsi:type="xsd:string">102208900</RefNum>
<TransKey xsi:type="xsd:string">lnfkx4pr89yq4yh</TransKey>
<Result xsi:type="xsd:string">Approved</Result>
<ResultCode xsi:type="xsd:string">A</ResultCode>
<Status xsi:type="xsd:string">Pending</Status>
<StatusCode xsi:type="xsd:string">P</StatusCode>
<VpasResultCode xsi:type="xsd:string"></VpasResultCode>
</captureTransactionReturn>
</ns1:captureTransactionResponse>
</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 {
//Setting RefNum from the original transaction
BigInteger RefNum = new BigInteger('12345678');
//Setting Amount to capture
Double Amount = new Double(12.34);
//Create Transaction Response
TransactionResponse Response;
Response = client.captureTransaction(token,RefNum,Amount);
} catch (Exception e) {
System.out.println("Soap Exception: " + e.getMessage());
}
Change Log
Version | Change |
---|---|
1.7 | TransKey can be used in RefNum field. |