How to integrate a FoxyCart store with Token of Trust for Excise Tax Collection


Step 1. Creating a Token of Trust account


You will need to create a Token of Trust account that you can connect your FoxyCart store to. To do this head to https://app.tokenoftrust.com/hq/register

  • Enter your email
  • For company URL enter your live site URL to your FoxyCart store.
  • Fill out the additional info for registration such as country and phone number until you are completed with the signup and arrive at the dashboard homescreen

Step 2. Creating a FoxyCart Externally Controlled Coupon


In order for Token of Trust to add excise taxes to the cart, there needs to be a new coupon for the store that is externally controlled (by us), so that we can dynamically change the coupon amount


  1. Go to admin.foxycart.com and log in to your FoxyCart admin account for your store
  2. Under the Product section, click on coupons
  3. In the select a coupon drop down, pick Add a New Coupon, and fill out the information as below
  4. Coupon name: TOT Excise Tax Coupon
  5. In the field for 'import codes, one per line' paste in: tot_excise_tax
  6. Discount method: Externally controlled discount
  7. Coupon details: 0
  8. Combinable: Check the box
  9. Multiple codes allowed: Don't check the box
  10. Shared codes allowed: Don't check the box
  11. Taxable: Don't check the box
  12. Category discounts: Don't check the box
  13. Line item discounts: Don't check the box
  14. Everything else should stay the same, make sure it is set up to apply to all categories and it doesnt have and date restrictions or number of uses restrictions
  15. Click Create Coupon and then make sure the coupon looks like this when you view it:

Step 3. Setting up FoxyCart Webhook for Order Reconciliation


Token of Trust needs to listen to when an order was placed, so we can reconcile the taxes on that order. First we must set up that webhook in FoxyCart admin panel


  1. In the same Integrations section under Account, scroll to the webhooks next section at the top.
    1. Select JSON WEBHOOK and then Add one more URL
    2. Name: "TOT Order Reconciliation"
    3. URL: https://foxycart.tokenoftrust.com/webhooks/foxycart-transaction
    4. Encryption key: please use the totSecretKey which can be found from the Token of Trust account you created earlier
      1. To find it, log into app.tokenoftrust.com/hq/signin
      2. Once logged in navigate to https://app.tokenoftrust.com/hq/guides/integration
      3. Scroll to the REST API Integration section.
      4. Copy the value of SECRET KEY (totSecretKey)
    5. Subscribed resources: "Transaction"
    6. API filter query string (it should default to this):
zoom=applied_taxes,billing_addresses,custom_fields,customer,discounts,items,items:item_category,items:item_options,payments,shipments
  1. Click Update Webhooks Next
    1. It should look similar to this when done


Step 4. Setting up FoxyCart Webhook for adding excise taxes to cart

Token of Trust needs to listen to what items are in a cart, their quantities, their prices etc, so that we can add our excise taxes back on to the cart in real time. To do that we must go to the FoxyCart admin panel

  1. Go to admin.foxy.io and log in to your FoxyCart account for your store
  2. On the left side of the screen, you should see API Browser close to the bottom, and click on it
  3. Scroll to the bottom of this page and click: Configured webhooks for this Store. fx:webhooks
    1. It should look something like this:
  4. On this page, you should see one webhook already set up, which is the one we set up earlier
  5. At the top right select POST which should bring you to a page that looks like this:
  6. Delete the {} so that it is an empty field, and paste in this data:
  {
  "format": "pre_cart",
  "version": 2,
  "name": "Token of Trust Pre-Cart",
  "url": "https://foxycart.tokenoftrust.com/webhooks/foxycart-precart",
  "query": "zoom=discounts,customer,items,items:item_options,items:item_category,items:coupon_details,items:discount_details,applied_coupon_codes",
  "encryption_key": "",
  "event_resource": "cart",
  "config": null
}
  1. Click submit on the right side to submit these changes
    1. This UI is a little buggy, and to verify that it actually submitted you should refresh the browser page, go back to API Browser and fx:webhooks and verify you can now see the second webhook added

Step 5. Getting Coupon Code ID


Since we are logged into the admin.foxy.io panel already, we need to get the ID number for the coupon code we created earlier. Unfortunately the page where we created this coupon at does not give us this information, but admin.foxy.io panel does.


  1. Log back into admin.foxy.io if you logged out
  2. On the left hand side panel, click Coupons
  3. Select the coupon you created earlier (It should be called (TOT Excise Tax Coupon)
  4. The Coupon code ID we are looking for should be right under the coupon name and it will begin with a #
  5. Example in this photo my coupon ID is #220469

  1. Send this coupon ID to developers@tokenoftrust.com and let them know you created the TOT Excise Tax Coupon for your store, so that way we can be configured to look for it!

Step 6. Adding Excise Tax Products to Token of Trust


We now have Token of Trust integration with FoxyCart, but in order to start calculating taxes on orders, we need to match cart products to products in Token of Trust.


How to update product metadata shows you what product metadata is and how it can be created in a way that can be used by Token of Trust support team to get your products into Token of Trust.



Step 7. Make sure everything is working smoothly.


Once you have completed these steps an a Token of Trust employee has configured stuff on their side for you, then everything should be set up and it is time to test out that you can calculate taxes on checkout! Go ahead and go to your FoxyCart store and add an item to your cart that you know will have excise taxes (e.g. a nicotine product) and go to checkout with it. Add an address to ship to and you should see excise taxes being calculated in the discounts seection


Example:


Frequently Asked Questions


Q: How long will this take to do the integration steps?

A: Shouldn't be more than 30 minutes - not counting the metadata setup.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us