Skip to main content
Vindicia Knowledge Center




The calculateSalesTax method calculates the sales tax of a Transaction object.

Transactions may be taxable by several local and state governments. For example, in the United States, depending on the address, a transaction might be taxable by the city, county, and state. For each applicable tax, this method adds a line item to your Transaction (see the Transaction object’sitems data member).

The Vindicia Subscribe sales-tax engine works as follows:

  1. Taxes are collected according to the buyer’s address. If the shipping address is specified on the Transaction, Vindicia Subscribe considers that address for tax calculation first. If not, Vindicia Subscribe uses the billing address on the payment method. In the absence of those two addresses, Vindicia Subscribe cannot calculate the taxes. For U.S. and Canadian addresses, be sure to provide full address information since taxes vary from state to state and, in many cases, from city to city.
  2. Vindicia Subscribe “cleans up” the address chosen to apply taxes. For example, Vindicia Subscribe converts Saint Fort, Sainte Fort, or Ste Fort to St Fort, discards punctuation marks, and converts dashes to spaces.
  3. Vindicia Subscribe “fixes up” the address in question, by correcting misspelled street or city names, and by applying the correct postal code according to the street address. Vindicia Subscribe does not change the actual address in the Transaction object; instead, Vindicia Subscribe stores the corrected address in the Transaction object’s salesTaxAddress data member when returning the object to you. This step enables the Vindicia Subscribe sales-tax engine to pinpoint the correct final jurisdiction (country, district, county, city, and postal code) to calculate taxes.
  4. Vindicia Subscribe looks in a database for the applicable tax rates for the jurisdiction. That database is continually updated with the latest information.

Customize the applicable tax rates as follows:

  • Upload overriding tax rules to the Vindicia database. In those rules, you may define a specific tax rate for Vindicia Subscribe to apply to your transactions if the customer address is in a specific city, county, state, or other location. You may also specify a date range for applying those tax rules. For more information, contact your Vindicia Client Services representative.
  • Specify your tax nexus. In the United States, your tax nexus is the set of local and state governments that may collect sales tax on your transactions. This nexus depends on the physical location of your business registration. For example, if your company is registered only in California, only the State of California may collect sales tax on your transactions, and Vindicia Subscribe applies sales tax only if your customer’s address is also in California. Contact your Vindicia Client Services representative for more information.
  • Define the tax exemptions on your customer accounts. See the taxExemptions attribute in The Account Object.
  • Define the tax classification on your Product and TransactionItem objects. The tax classification enables you to specify the categories, such as physical goods and electronic data, to which your sales items belong. If your nexus specifies that an item is taxable, Vindicia Subscribe applies sales tax accordingly. See the taxClassification attribute in The Product Object, and in the TransactionItem Subobject.

Vindicia Subscribe includes sales tax items added to your Transaction as new items in the returned Transaction object. The names of those transaction items begin with the prefix VIN, for example,VIN_SALES_TAX_STATE. Vindicia Subscribe also adds a line item that contains the total amount of all the tax items with the name VIN_SALES_TAX.

Note that the calculateSalesTax method does not save the transaction sent for tax calculation in the Vindicia Subscribe database. When a customer makes a one-time purchase on your site, create a Transaction object and call calculateSalesTax on it to calculate the applicable taxes. Vindicia Subscribe will return the total amount of the purchase after adding the applicable taxes. Then present the amount to your customer. Once the customer has finalized the purchase, capture the transaction by calling authCapture on the original Transaction.

The calculateSalesTax call will handle a tax-based timeout, returning a 503 error if the tax calculation has timed out. Given this error, you may choose to abandon or cancel the Transaction. If you ignore this error, sales tax is not calculated.

The authCapture() and auth() methods automatically calculate and add taxes to a transaction before processing it with the payment processor. Vindicia Subscribe also adds applicable sales tax to recurring billing transactions generated for AutoBill objects.


srd: sparse response description, a SOAP string (which must be a JSON object), in which you specify the elements you want returned.This parameter enables the calling system to constrain a method call to return only components you specify. This gives you greater control over returned content, and improves response time within the Vindicia platform by reducing the processing needed for the call.

Some fields are required, either practically or in the WSDL, and will be returned regardless of the srd. A null srd returns the complete response.

transaction: the Transaction object for which to calculate sales tax. This object must have an address and a line item that describes the product sold, as well as a price. Identify this object with either its VID or your merchantTransactionId.


return: an object of type Return that indicates the success or failure of the call.

transaction: the Transaction object that contains the added tax line items, the total amount with the total sales tax added, and the salesTaxAddress attribute filled in with the (corrected) address used to compute taxes.

addressType: the address Vindicia Subscribe chose to calculate sales tax. This parameter has a value of either Shipping or Billing.

originalAddress: the original value of the address chosen by Vindicia Subscribe for tax calculation.

correctedAddress: the final value of the selected address, after Vindicia Subscribe has corrected inconsistencies.

taxItems: an array of SalesTax objects, each of which contains a description attribute, which describes a specific type of tax added (for example, city tax); and a tax attribute, which contains the amount of the tax calculated by Vindicia Subscribe.

totalTax: the total sales tax calculated by Vindicia Subscribe.


In addition to those listed in Standard Return Codes, this call returns:

Return Code

Return String


One of the following:

  • Address not specified on transaction, and unable to load it from customer accounts - unable to calculate sales tax!
  • Must specify line items in transaction to calculate sales tax!


Tax service temporarily unavailable.


$tx = new Transaction();


$account = new Account();
$account->setName('J Doe');

$shippingAddress = new Address();
$shippingAddress->setName('Jane Doe');
$shippingAddress->setAddr1('44 Elm St.');
$shippingAddress->setCity('San Mateo');


// The line items of the transaction

$tx_item = new TransactionItem();

$paymentMethod = new PaymentMethod();
$ccCard = new CreditCard();


$response = $tx->calculateSalesTax();
if ($response['returnCode'] == 200) {

print "Address type used for computing tax: ";
print $response['addressType'] . "\n";
print "Taxes added: \n";
$taxes = $response['taxItems'];
foreach($taxes as $tax) {

print $tax->getDescription() . " : " ;
print $tax->getTax() . "\n";


print "Total tax: " . $response['totalTax'];
print "Total transaction amount: " ;
print $response['transaction']->getAmount() . "\n";


For Users

Learn More
For Users

Vindicia Subscribe Features

Learn More
Vindicia Subscribe Features
Back to Top