Calculate and display shopping cart taxes
When selling internationally, charging the appropriate amount for taxes can be tricky, as the correct taxation can depend on the shopper's country or US state, the product type, and the order total amount.
However, merchants on the 2Monetize package do not have to worry, as the API calculates and handles the VAT and Sales taxes based on the order information.
Availability
Available to all 2Checkout accounts.
getContents API method
Information about VAT and sales taxes is handled by the getContents (for JSON-RPC and SOAP protocols) or by making a PUT request to /orders/0/ on REST.
This API method will take into account the product configuration (NET or GROSS price type, product category, pricing options, etc.), any marketing campaign (like discounts) together with the shopper's location, and return all the information needed to display to the shopper.
Request object
The getContents API call accepts as input an order object, the same object used for placing an order. However, the only required objects for calculating the taxes are the items information (what products the shopper has in their cart) and the BillingDetails (needed in order to locate the customer and retrieve the taxes that should be applied).
Switching the currency
Switching the currency and converting prices is supported both for prices set in multiple currencies in the product configuration, as well as on the fly.
In order to do this, the currency ISO code needs to be updated in the root object Currency element.
Request sample
Response object
The API will respond with the full order object, including the price and tax information, both on a line item (unit) level as well as on a cart level.
Unit price information
Per LineItem, each product contains a Price object, with all relevant information for the product's price and taxes:
Currency
String
The currency ISO 4217 code; This currency is used in all the price values for that product. Example: USD.
UnitNetPrice
Float
The value per product unit (quantity = 1), excluding sales tax/VAT. Discounts are not reflected in this price.
UnitGrossPrice
Float
Total value per product unit (quantity = 1), including sales tax/VAT. Discounts are not reflected in this price.
UnitVAT
Int
Sales tax/VAT per product unit.
UnitNetDiscountedPrice
Float
The value per product unit, excluding sales tax/VAT, from which 2Checkout deducts the unit discount.
UnitGrossDiscountedPrice
Float
Total costs shoppers incur per product unit. This value includes sales tax/VAT, 2Checkout, and affiliate commissions, but 2Checkout deducts the value of any discounts.
VATPercent
Int
Percentage of VAT charged on the order.
VAT
Float
Value of VAT per order line.
Discount
Float
Value of the discounts per order line expressed in the payment currency.
NetDiscountedPrice
Float
The NetPrice value per order line, excluding sales tax/VAT, from which 2Checkout deducts discounts.
GrossDiscountedPrice
Float
Total costs shoppers incur per order line. This value includes sales tax/VAT, 2Checkout, and affiliate commissions, but 2Checkout deducts the value of any discounts.
Order price information
On the order level, in the response object root level, you can find all relevant information for the order's price and taxes:
NetPrice
Float
Order value excluding sales tax/VAT.
GrossPrice
Float
Total order value, including sales tax/VAT. GrossPrice does not reflect any discounts.
NetDiscountedPrice
Float
The NetPrice order value excluding sales tax/VAT, from which 2Checkout deducts discounts.
GrossDiscountedPrice
Float
Total costs shoppers incur. This value includes sales tax/VAT, 2Checkout, and affiliate commissions, but 2Checkout deducts the value of any discounts.
Discount
Float
Value of the discounts for an order.
VAT
Float
Value of sales tax/VAT.
Integration test cases
Create a simple product (be it a catalog product in the Control Panel, or a dynamic product), using a round number as the price (like 100) in order to be able to easily check the calculated taxes.
Using the getContents API call, build your checkout flow, and display the taxes as needed.
As an easy comparison, you can use a catalog product and generate a buy-link in ConvertPlus and compare the way the taxes are displayed.
If needed, implement the currency switching in the checkout flow.
Keep in mind that, where prices in other currencies are specified in the product catalog, they will be used instead of the prices automatically converted by 2Checkout.
Last updated
Was this helpful?