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’s items data member).
The Subscribe sales-tax engine works as follows:
- Taxes are collected according to the buyer’s address. If the shipping address is specified on the
Transaction, Subscribe considers that address for tax calculation first. If not, Subscribe uses the billing address on the payment method. In the absence of those two addresses, 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. - Subscribe “cleans up” the address chosen to apply taxes. For example, Subscribe converts SAINT FORT, SAINTE FORT, or STE FORT to ST FORT, discards punctuation marks, and converts dashes to spaces.
- 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. Subscribe does not change the actual address in the
Transactionobject; instead, Subscribe stores the corrected address in theTransactionobject’ssalesTaxAddressdata member when returning the object to you. This step enables the Subscribe sales-tax engine to pinpoint the correct final jurisdiction (country, district, county, city, and postal code) to calculate taxes. - Subscribe looks in a database for the applicable tax rates for the jurisdiction. That database is continually updated with the latest information.
- Upload overriding tax rules to the Vindicia database. In those rules, you may define a specific tax rate for 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 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
taxExemptionsattribute in The Account Object. - Define the tax classification on your
ProductandTransactionItemobjects. 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, Subscribe applies sales tax accordingly. See thetaxClassificationattribute in The Product Object, and in the TransactionItem Subobject.
Transaction object. The names of those transaction items begin with the prefix VIN, for example, VIN_SALES_TAX_STATE. 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 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. 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. Subscribe also adds applicable sales tax to recurring billing transactions generated for AutoBill objects.
Input
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 amethod 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.
Output
return: an object of typeReturn 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 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 Subscribe for tax calculation.
correctedAddress: the final value of the selected address, after 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 Subscribe.
totalTax: the total sales tax calculated by Subscribe.

