Implementation, Transaction Processing: Authorizing Transactions

Step 5: Authorizing Transactions

The following operations are used to authorize transactions for both SOAP and REST implementations:

Authorize Operations  
Authorize (BCP, ECK/ACH only, SVA) AuthorizeAndCapture (BCP, SVA)

Note: Host capture systems typically require the implementation of the AuthorizeAndCapture operation, while terminal capture systems typically require the implementation of the Authorize operation.

For more information, refer to Transaction Processing Guidelines.

Important! All parameters in each operation are considered "required" unless otherwise noted. 

 


Authorize

The Authorize operation is used to authorize transactions by performing a check on cardholder's funds and reserves the authorization amount if sufficient funds are available. Unlike the AuthorizeAndCapture operation, Authorize transactions must then be flagged for settlement by invoking the Capture operation.

Note: Authorize is not supported when processing PIN Debit transactions on terminal capture systems. For more information, refer to Terminal Capture Operation Flows.

Implementation Notes

The following implementation notes are specific to the Authorize operation:

  • Visa and MasterCard support authorizations of $0.00.
  • American Express and Discover do not support authorizations of $0.00.
  • Discover supports the reversal (void) of authorizations, so the reversal will not show on the cardholder's statement.
  • American Express does not support the reversal (void) of authorizations. Any authorized amount will roll off after 30 days and will show on the cardholder's statement.
  • Be sure to set a unique OrderNumber in the BankcardTransactionData object. This ensures fast and convenient recovery of transactionIds in the event of communication failures.
  • The BankcardTransactionPro object is required to support BankcardInterchangeData used for recurring, installment, and deferred billing payments.
  • The BankcardTransactionDataPro object is required to support Level 2 and/or Level 3 transaction data.

SOAP

Operation

Response Authorize(string sessionToken, Transaction transaction, string applicationProfileId, MerchantProfile merchantProfile, string merchantProfileId, string workflowId);

Parameters

Parameter Data Type Description
sessionToken String The short-lived token used to authenticate to CWS.
transaction Transaction Transaction detail data.
Note: You must send in BankcardTransaction 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.
merchantProfile MerchantProfile Conditional. The specific Merchant Profile to include in the transaction request. Required only if supporting Unmanaged Merchant Profiles (UMP).
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 servideId returned by GetServiceInformation.

Return Type

Data Type Description
Response Transaction response data.
Note: For Bankcard (BCP) transactions, the response object is BankcardTransactionResponsePro.
For Electronic Checking (ECK) transactions, the response object is ElectronicCheckingTransactionResponse.
For Stored Value Account (SVA) transactions, the response object is StoredValueTransactionResponse.

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.

PHP Code Sample

<?php
    
    require_once(dirname(__FILE__) . '/Client.php'); //<---Contains cURL function that sends any transaction related call. 
	require_once(dirname(__FILE__) . '/TransactionClasses.php');//<---Contains classes needed for transaction.
    require_once(dirname(__FILE__) . '/ServiceCalls.php');//<---Takes care of all SignOn, service, and merchant profile needs.
    

	 /*
	 *Transaction Processing 
	 *\See TransactionClasses.php 
	 */
 		$cardData = new CardData();
		$cardData->PAN = "5100000000000016";
		$cardData->Expire = "1215";
		$cardData->CardType = "MasterCard";

		
		$tenderData = new TenderData();
		$tenderDataParam = '<ns1:TenderData>
								<ns1:CardData>
									<ns1:CardType>'. $cardData->CardType .'</ns1:CardType>
									<ns1:PAN>'.$cardData->PAN . '</ns1:PAN>
									<ns1:Expire>'.$cardData->Expire . '</ns1:Expire>
								</ns1:CardData>
							</ns1:TenderData>';
		
		
		
		$dt = date('Y-m-d H:i:s');
        $datetime = str_replace (" ", "T", $dt);
		$transactionData = new TransactionData();
		$transactionData->EntryMode = 'Keyed';
		$transactionData->CustomerPresent = 'Ecommerce';
		$transactionData->TransactionDateTime = $datetime;
		$transactionData->OrderNumber = '123456';
		$transactionData->SignatureCaptured = 'false';
		$transactionData->Amount = '12.00';
		$transactionData->CurrencyCode = 'USD';
		$transactionData->EmployeeId = '11';
		$transactionDataParam = '<ns1:TransactionData>
									<ns8:Amount xmlns:ns8="http://schemas.ipcommerce.com/CWS/v2.0/Transactions">'.$transactionData->Amount.'</ns8:Amount>
									<ns1:CurrencyCode>'.$transactionData->CurrencyCode.'</ns1:CurrencyCode>																		
									<ns10:TransactionDateTime xmlns:ns10="http://schemas.ipcommerce.com/CWS/v2.0/Transactions">'. $transactionData->TransactionDateTime . '</ns10:TransactionDateTime>
									<ns1:CustomerPresent>'.$transactionData->CustomerPresent.'</ns1:CustomerPresent>
									<ns1:EmployeeId>' . $transactionData->EmployeeId . '</ns1:EmployeeId>
									<ns1:EntryMode>'. $transactionData->EntryMode . '</ns1:EntryMode>
									<ns1:OrderNumber>' . $transactionData->OrderNumber . '</ns1:OrderNumber>
									<ns1:SignatureCaptured>'.$transactionData->SignatureCaptured.'</ns1:SignatureCaptured>
								 </ns1:TransactionData>';
		
		$transaction = new Transaction();
		$transaction->TransactionData = $transactionDataParam;
		$transaction->TenderData = $tenderDataParam;
		$transactionParam = $tenderDataParam . $transactionDataParam;
		
		
		$transactionAuthOnly = '<?xml version="1.0" encoding="UTF-8"?>
							<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
							. '<SOAP-ENV:Body>
								<Authorize xmlns="http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing">
								  <sessionToken>'.$sessionTokenString.'</sessionToken>
								  <transaction xmlns:ns1="http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard" xsi:type="ns1:BankcardTransaction">'
								  .$tenderDataParam.
								   $transactionDataParam.
							     '</transaction>'
								  .'<applicationProfileId>'.$applicationIdString.'</applicationProfileId>'
								  .'<merchantProfileId>'.$merchantProfileId.'</merchantProfileId>'
								  .'<workflowId>'.$serviceId.'</workflowId>'
								.'</Authorize>
							   </SOAP-ENV:Body>
							</SOAP-ENV:Envelope>';
		
        $call = 'Authorize';
		$xmlRequest = $transactionAuthOnly;
		
		$response = curl_call($xmlRequest, $sessionTokenString, $call);
		
		if($response[0] != '')
		{
			echo nl2br("<h1>AuthorizeOnly Transaction Results</h1> \r\n 
				<h3>StatusMessage: " . $response[0] . "</h3> 
				<h3>StatusCode: "    . $response[1] . "</h3> 
				<h3>TransactionId: " . $response[2] . "</h3> \r\n\r\n
				<h1>We now have a stored AuthorizeOnly transaction 
					that can be acted on later using the TransactionId</h1>");
	    } else {
     		echo nl2br("<h1>Something Went Wrong</h1>");
	      	}
		
?>

 

C# Code Sample

var authRequest = new BankcardTransaction()
{
	TenderData = new BankcardTenderData()
	{
		CardData = new CardData()
		{
			CardType = TypeCardType.Visa,
			PAN = "5100000000000016",
			Expire = "1215",
		},
		CardSecurityData = new CardSecurityData()
		{
			AVSData = new AVSData()
			{
				Street = "123 Rain Road",
				City = "Aurora",
				StateProvince = "CO",
				PostalCode = "80080",
			},
			CVData = "383",
			CVDataProvided = CVDataProvided.Provided,
		},
	},
	TransactionData = new BankcardTransactionData()
	{
		CurrencyCode = NabVelocity.Txn.TypeISOCurrencyCodeA3.USD,
		OrderNumber = "123456",
		Amount = 15.00M,
		EntryMode = NabVelocity.Txn.EntryMode.Keyed,
		IndustryType = NabVelocity.Txn.IndustryType.Ecommerce,
	},
};

var authResponse = (BankcardTransactionResponse)txnClient.Authorize(sessionToken, authRequest,
	applicationProfileId, merchantProfileId, serviceId);

Console.WriteLine("(Authorize) Status: " + authResponse.Status + "\r\n"
				+ "Amount: " + authResponse.Amount + "\r\n"
				+ "ApprovalCode: " + authResponse.ApprovalCode + "\r\n"
				+ "TransactionId: " + authResponse.TransactionId + "\r\n");

REST

Note: The HTTP Authorization Header must contain the required sessionToken value.

Operation

URL https://api.cert.nabcommerce.com/REST/2.0.18/Txn/{workflowId}
UMP URL https://api.cert.nabcommerce.com/REST/2.0.18UMP/Txn/{workflowId}
Action POST

Parameters

Parameter Data Type Description
workflowId String Identifies the workflow to use for the transaction. If not supporting custom workflows, pass the servideId returned by GetServiceInformation.

Message Body Type

Data Type Description
Rest.AuthorizeTransaction The message body containing transaction data.
Rest.AuthorizeTransactionWithProfile The message body containing transaction data and complete MerchantProfile required by UMP implementations.

Return Type

Data Type Description
Response Transaction response data.
Note: For Bankcard (BCP) transactions, the response object is BankcardTransactionResponsePro.
For Electronic Checking (ECK) transactions, the response object is ElectronicCheckingTransactionResponse.
For Stored Value Account (SVA) transactions, the response object is StoredValueTransactionResponse.

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.

 


AuthorizeAndCapture

The AuthorizeAndCapture operation is used to authorize transactions by performing a check on cardholder's funds and reserves the authorization amount if sufficient funds are available, and flags the transaction for capture (settlement) in a single invocation.

Note: The AuthorizeAndCapture operation should always be used for PIN Debit transactions regardless of processing host type. PIN Debit transactions are automatically captured for settlement even if they are not specifically captured using CaptureAll or CaptureSelective.

Authorize is not supported when processing PIN Debit transactions on terminal capture systems. For more information, refer to Host Capture Operation Flows.

Implementation Notes

The following implementation notes are specific to the AuthorizeAndCapture operation:

  • Visa and MasterCard support authorizations of $0.00.
  • American Express and Discover do not support authorizations of $0.00.
  • Discover supports the reversal (void) of authorizations, so the reversal will not show on the cardholder's statement.
  • American Express does not support the reversal (void) of authorizations. Any authorized amount will roll off after 30 days and will show on the cardholder's statement.
  • Be sure to set a unique OrderNumber in the BankcardTransactionData object. This ensures fast and convenient recovery of transactionIds in the event of communication failures.
  • The BankcardTransactionPro object is required to support BankcardInterchangeData used for recurring, installment, and deferred billing payments.
  • The BankcardTransactionDataPro object is required to support Level 2 and/or Level 3 transaction data.

SOAP

Operation

Response AuthorizeAndCapture(string sessionToken, Transaction transaction, string applicationProfileId, MerchantProfile merchantProfile, string merchantProfileId, string workflowId);

Parameters

Parameter Data Type Description
sessionToken String The short-lived token used to authenticate to CWS.
transaction Transaction Transaction detail data.
Note: You must send in BankcardTransaction 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.
merchantProfile MerchantProfile Conditional. The specific Merchant Profile to include in the transaction request. Required only if supporting Unmanaged Merchant Profiles (UMP).
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 servideId returned by GetServiceInformation.

Return Type

Data Type Description
Response Transaction response data.
Note: For Bankcard (BCP) transactions, the response object is BankcardTransactionResponsePro.
For Electronic Checking (ECK) transactions, the response object is ElectronicCheckingTransactionResponse.
For Stored Value Account (SVA) transactions, the response object is StoredValueTransactionResponse.

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.

PHP Code Samples

 
<?php
/*
 * SignOnWithToken 
 */
    //$identityToken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPSIxIiBBc3NlcnRpb25JRD0iX2Q2Zjg1Zjg5LWEzMmEtNDIwYS04NGMyLTdjNmZjMDVlYWZhMSIgSXNzdWVyPSJJcGNBdXRoZW50aWNhdGlvbiIgSXNzdWVJbnN0YW50PSIyMDE0LTA0LTAyVDE5OjQwOjUxLjc5OFoiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjEuMDphc3NlcnRpb24iPjxzYW1sOkNvbmRpdG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nRvcDlnWnBxK0xxM2tTYmZpTDdhUEwrK0RiU0h5WEN6YmZLblNRLy95TEk5NGNvMWphRkYvR1dOVUdYQTJFY3k2djlhWThnekdsUEVpdTVEakdIK25MY056ejdOdEFwTFRvQW42OHFHdlF6dUU3K3NZeFBxNzNqS1hqZHlOMUh1UnBYeVkzOHpacFA4S2pORnBUdkVwOW1rUDlUMGtiNXNyQ1BuR3FpaDIxWjRaMnlRWjhWZjVCMndUQlJlbWZQUXJ0YXgxWWdxd3h2UlFLQjVYZXcydXl2K0p4U0VaUHRRdTFRN0VQSFZjSExjTy80c1Q2Q25ueHplaVYxMjlJMllHRzFEc1JBazN3PT08L1NpZ25hdHVyZVZhbHVlPjxLZXlJbmZvPjxvOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2UgeG1sbnM6bz0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzLzIwMDQvMDEvb2FzaXMtMjAwNDAxLXdzcy13c3NlY3VyaXR5LXNlY2V4dC0xLjAueHNkIj48bzpLZXlJZGVudGlmaWVyIFZhbHVlVHlwZT0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzL29hc2lzLXdzcy1zb2FwLW1lc3NhZ2Utc2VjdXJpdHktMS4xI1RodW1icHJpbnRTSEExIj5ZREJlRFNGM0Z4R2dmd3pSLzBwck11OTZoQ2M9PC9vOktleUlkZW50aWZpZXI+PC9vOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2U+PC9LZXlJbmZvPjwvU2lnbmF0dXJlPjwvc2FtbDpBc3NlcnRpb24+";
    require_once(dirname(__FILE__) . '/Client.php'); //<---Contains cURL function that sends any transaction related call. 
	require_once(dirname(__FILE__) . '/TransactionClasses.php');
    require_once(dirname(__FILE__) . '/ServiceCalls.php');
	 /*
	 *Transaction Processing 
	 *\See TransactionClasses.php 
	 */
 		$cardData = new CardData();
		$cardData->PAN = "5100000000000016";
		$cardData->Expire = "1215";
		$cardData->CardType = "MasterCard";

		
		$tenderData = new TenderData();
		$tenderDataParam = '<ns1:TenderData>
								<ns1:CardData>
									<ns1:CardType>'. $cardData->CardType .'</ns1:CardType>
									<ns1:PAN>'.$cardData->PAN . '</ns1:PAN>
									<ns1:Expire>'.$cardData->Expire . '</ns1:Expire>
								</ns1:CardData>
							</ns1:TenderData>';
		$dt = date('Y-m-d H:i:s');
        $datetime = str_replace (" ", "T", $dt);
		$transactionData = new TransactionData();
		$transactionData->EntryMode = 'Keyed';
		$transactionData->CustomerPresent = 'Ecommerce';
		$transactionData->TransactionDateTime = $datetime;
		$transactionData->OrderNumber = '123456';
		$transactionData->SignatureCaptured = 'false';
		$transactionData->Amount = '12.00';
		$transactionData->CurrencyCode = 'USD';
		$transactionData->EmployeeId = '11';
		$transactionDataParam = '<ns1:TransactionData>
									<ns8:Amount xmlns:ns8="http://schemas.ipcommerce.com/CWS/v2.0/Transactions">'.$transactionData->Amount.'</ns8:Amount>
									<ns1:CurrencyCode>'.$transactionData->CurrencyCode.'</ns1:CurrencyCode>																		
									<ns10:TransactionDateTime xmlns:ns10="http://schemas.ipcommerce.com/CWS/v2.0/Transactions">'.$transactionData->TransactionDateTime.'</ns10:TransactionDateTime>
									<ns1:CustomerPresent>'.$transactionData->CustomerPresent.'</ns1:CustomerPresent>
									<ns1:EmployeeId>' . $transactionData->EmployeeId . '</ns1:EmployeeId>
									<ns1:EntryMode>'. $transactionData->EntryMode . '</ns1:EntryMode>
									<ns1:OrderNumber>' . $transactionData->OrderNumber . '</ns1:OrderNumber>
									<ns1:SignatureCaptured>'.$transactionData->SignatureCaptured.'</ns1:SignatureCaptured>
								 </ns1:TransactionData>';
		
		$transaction = new Transaction();
		$transaction->TransactionData = $transactionDataParam;
		$transaction->TenderData = $tenderDataParam;
		$transactionParam = $tenderDataParam . $transactionDataParam;
		
		
		$transactionAuthAndCapture = '<?xml version="1.0" encoding="UTF-8"?>
							<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
							. '<SOAP-ENV:Body>
								<AuthorizeAndCapture xmlns="http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing">
								  <sessionToken>'.$sessionTokenString.'</sessionToken>
								  <transaction xmlns:ns1="http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard" xsi:type="ns1:BankcardTransaction">'
								  .$tenderDataParam.
								   $transactionDataParam.
							     '</transaction>'
								  .'<applicationProfileId>'.$applicationIdString.'</applicationProfileId>'
								  .'<merchantProfileId>'.$merchantProfileId.'</merchantProfileId>'
								  .'<workflowId>'.$serviceId.'</workflowId>'
								.'</AuthorizeAndCapture>
							   </SOAP-ENV:Body>
							</SOAP-ENV:Envelope>';
		
        $call = 'AuthorizeAndCapture';
		$xmlRequest = $transactionAuthAndCapture;
		
		$response = curl_call($xmlRequest, $sessionTokenString, $call);
		
		if($response[0] != '')
		{
			echo nl2br("<h1>AuthorizeAndCapture Transaction Results</h1> \r\n 
				<h3>StatusMessage: " . $response[0] . "</h3> 
				<h3>StatusCode: "    . $response[1] . "</h3> 
				<h3>TransactionId: " . $response[2] . "</h3> \r\n\r\n
				<h1>We now have a stored AuthorizeOnly transaction 
					that can be acted on later using the TransactionId</h1>");
	    } else {
     		echo nl2br("<h1>Something Went Wrong</h1>");
	      	}
		
?>
 

C# Code Samples

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

REST

Note: The HTTP Authorization Header must contain the required sessionToken value.

Operation

URL https://api.cert.nabcommerce.com/REST/2.0.18/Txn/{workflowId}
UMP URL https://api.cert.nabcommerce.com/REST/2.0.18UMP/Txn/{workflowId}
Action POST

Parameters

Parameter Data Type Description
workflowId String Identifies the workflow to use for the transaction. If not supporting custom workflows, pass the servideId returned by GetServiceInformation.

Message Body Type

Data Type Description
Rest.AuthorizeAndCaptureTransaction The message body containing transaction data.
Rest.AuthorizeAndCaptureTransactionWithProfile The message body containing transaction data and complete MerchantProfile required by UMP implementations.

Return Type

Data Type Description
Response Transaction response data.
Note: For Bankcard (BCP) transactions, the response object is BankcardTransactionResponsePro.
For Electronic Checking (ECK) transactions, the response object is ElectronicCheckingTransactionResponse.
For Stored Value Account (SVA) transactions, the response object is StoredValueTransactionResponse.

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.

PHP Code Samples

/* $trans_info is class type transData
 * $amount and $tip_amount: ('#.##'} (At least $1, two decimals required (1.00))*/
 
public function authorizeAndCapture($credit_info, $trans_info, $processAsPro)
{
	if (! $this->signOn ())
		return false;
 
	if ($this->svc instanceof BankcardService || $this->svc == null)
	{
		// Bank Transaction Pro
		if ($processAsPro == true)
		{
			$Transaction = buildTransactionPro ( $credit_info, $trans_info );
			$TxnType = '"$type":"BankcardTransactionPro,http://schemas.nabcommerce.com/CWS/v2.0/Transactions/Bankcard/Pro",';
			$TxnDataType = '"$type":"BankcardTransactionDataPro,http://schemas.nabcommerce.com/CWS/v2.0/Transactions/Bankcard/Pro",';
		}
		// Bank Transaction
		else
		{
			$Transaction = buildTransaction ( $credit_info, $trans_info );
			$TxnType = '"$type":"BankcardTransaction,http://schemas.nabcommerce.com/CWS/v2.0/Transactions/Bankcard",';
			$TxnDataType = '"$type":"BankcardTransactionData,http://schemas.nabcommerce.com/CWS/v2.0/Transactions/Bankcard",';
		}
	}
	if ($this->svc instanceof ElectronicCheckingService)
	{
		$Transaction = buildACHTransaction($credit_info, $trans_info);
		$TxnType = '"$type":"ElectronicCheckingTransaction,http://schemas.nabcommerce.com/CWS/v2.0/Transactions/ElectronicChecking",';
		$TxnDataType = '"$type":"ElectronicCheckingTransactionData,http://schemas.nabcommerce.com/CWS/v2.0/Transactions/ElectronicChecking",';
	}
 
	$msgBody = new Rest_AuthorizeTransaction();
	$msgBody->ApplicationProfileId = $this->appProfileID;
	$msgBody->MerchantProfileId = $this->merchantProfileID;
	$msgBody->Transaction = $Transaction;
	$action = 'POST';
	$url = $this->txn.'/'.$this->workflowId;
 
	// Format the message
	$txnString = '"Transaction":{';
	$txnDataString = '"TransactionData":{';
	$msgBody = (string)json_encode($msgBody);
	$msgBody = str_replace('{"ApplicationProfileId"', '{"$type":"AuthorizeAndCaptureTransaction,http://schemas.nabcommerce.com/CWS/v2.0/Transactions/Rest","ApplicationProfileId"', $msgBody);
	$msgBody = str_replace($txnString, $txnString.$TxnType, $msgBody);
	$msgBody = str_replace($txnDataString, $txnDataString.$TxnDataType, $msgBody);
	$msgBody = str_replace(' ', '', $msgBody); // Make sure no spaces remain in the body.
	$response = curl_json($msgBody, $url, $action, $this->session_token);
	if(isset($response->body->ErrorId))
	{
		handleRestFault($response);
		return false;
	}
	if(isset($response[2]))
		return $response[2];		
}

C# Code Samples

public Response AuthorizeAndCapture(string sessionToken, Transaction transaction, string applicationProfileId, string merchantProfileId, string workflowId)
{
	var isJson = string.Equals(_msgFormat, MessageFormat.JSON.ToString());
	var requestString = RestBaseUri + "/" + workflowId;
	var restAuthTxn = new AuthorizeAndCaptureTransaction();
	restAuthTxn.ApplicationProfileId = applicationProfileId;
	restAuthTxn.MerchantProfileId = merchantProfileId;
 
	// Since 'transaction' references the service reference, this needs to be converted to use the Generated Proxie data contracts.
	// If using REST this step should be avoided by using the generated proxies directly throughout your application. 
	Type type = transaction.GetType();
	if (type == typeof(BankcardTransaction))
		restAuthTxn.Transaction = Utilities.SwapObjectsNamespace(transaction);
	else if (type == typeof(BankcardTransactionPro))
		restAuthTxn.Transaction = Utilities.SwapObjectsNamespace(transaction);
	else if (type == typeof(ElectronicCheckingTransaction))
		restAuthTxn.Transaction = Utilities.SwapObjectsNamespace(transaction);
	else if (type == typeof(StoredValueTransaction))
		restAuthTxn.Transaction = Utilities.SwapObjectsNamespace(transaction);
	else if (type == typeof(Transaction))
		restAuthTxn.Transaction = Utilities.SwapObjectsNamespace(transaction);
 
	var request = RestHelper.CreateRestRequest(restAuthTxn, requestString, HttpMethod.POST, sessionToken, isJson);
	try
	{
		if (isJson)
			return RestHelper.GetResponse(request, isJson);
		// For XML the specifc expect response needs to be passed so that it can be deserialized properly. 
		if (type == typeof(BankcardTransactionPro) || type == typeof(BankcardTransaction))
			return RestHelper.GetResponse(request, isJson);
		if (type == typeof(ElectronicCheckingTransaction))
			return RestHelper.GetResponse(request, isJson);
		if (type == typeof(StoredValueTransaction))
			return RestHelper.GetResponse(request, isJson);
	}
	catch (Exception ex)
	{
		RestFaultHandler.HandleFaultException(ex, isJson); 
	}
}

Comments