taxjar

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 13 Imported by: 0

README

TaxJar Sales Tax API for Go GitHub tag (latest SemVer) GoDoc Build Status

TaxJar

Official Go client for Sales Tax API v2. For the API documentation, please visit https://developers.taxjar.com/api/reference/.


Requirements
Installation
Authentication
Usage
Error Handling
Optional Configuration
Sandbox Environment
Testing


Requirements

Installation

go get -u github.com/taxjar/taxjar-go
// Then, import the package:
import "github.com/taxjar/taxjar-go"

Authentication

Generate a TaxJar API token. Enter the token when instantiating with NewClient. You may want to utilize an environment variable such as TAXJAR_API_KEY as seen below:

func NewClient(config ...Config) Config

// Instantiate client with your TaxJar API token:
client := taxjar.NewClient(taxjar.Config{
	APIKey: os.Getenv("TAXJAR_API_KEY"),
})
// or configure client after instantiating:
client := taxjar.NewClient()
client.APIKey = os.Getenv("TAXJAR_API_KEY")

You're now ready to use TaxJar! Check out our quickstart guide to get up and running quickly.

Usage

Categories - List all tax categories
TaxForOrder - Calculate sales tax for an order
ListOrders - List order transactions
ShowOrder - Show order transaction
CreateOrder - Create order transaction
UpdateOrder - Update order transaction
DeleteOrder - Delete order transaction
ListRefunds - List refund transactions
ShowRefund - Show refund transaction
CreateRefund - Create refund transaction
UpdateRefund - Update refund transaction
DeleteRefund - Delete refund transaction
ListCustomers - List customers
ShowCustomer - Show customer
CreateCustomer - Create customer
UpdateCustomer - Update customer
DeleteCustomer - Delete customer
RatesForLocation - List tax rates for a location (by zip/postal code)
NexusRegions - List nexus regions
ValidateAddress - Validate an address
Validate - Validate a VAT number
SummaryRates - Summarize tax rates for all regions


List all tax categories (API docs)

The TaxJar API provides product-level tax rules for a subset of product categories. These categories are to be used for products that are either exempt from sales tax in some jurisdictions or are taxed at reduced rates. You need not pass in a product tax code for sales tax calculations on product that is fully taxable. Simply leave that parameter out.

func (client *Config) Categories() (*CategoriesResponse, error)

res, _ := client.Categories()
fmt.Println(res.Categories) // CategoriesResponse.Categories
Calculate sales tax for an order (API docs)

Shows the sales tax that should be collected for a given order.

func (client *Config) TaxForOrder(params TaxForOrderParams) (*TaxForOrderResponse, error)

res, _ := client.TaxForOrder(taxjar.TaxForOrderParams{
	FromCountry: "US",
	FromZip:     "94025",
	FromState:   "CA",
	FromCity:    "Menlo Park",
	FromStreet:  "2825 Sand Hill Rd",
	ToCountry:   "US",
	ToZip:       "94303",
	ToState:     "CA",
	ToCity:      "Palo Alto",
	ToStreet:    "5230 Newell Road",
	Amount:      267.9,
	Shipping:    0,
	LineItems:   []taxjar.TaxLineItem{
		{
			ID:             "1",
			Quantity:       1,
			ProductTaxCode: "19005",
			UnitPrice:      535.8,
			Discount:       267.9,
		},
	},
})
fmt.Println(res.Tax) // TaxForOrderResponse.Tax
fmt.Println(res.Tax.AmountToCollect) // TaxForOrderResponse.Tax.AmountToCollect
List order transactions (API docs)

Lists existing order transactions created through the API.

func (client *Config) ListOrders(params ListOrdersParams) (*ListOrdersResponse, error)

res, _ := client.ListOrders(ListOrdersParams{
	FromTransactionDate: "2015/05/01",
	ToTransactionDate:   "2015/05/31",
})
fmt.Println(res.Orders) // ListOrdersResponse.Orders
Show order transaction (API docs)

Shows an existing order transaction created through the API.

func (client *Config) ShowOrder(transactionID string, params ...ShowOrderParams) (*ShowOrderResponse, error)

res, _ := client.ShowOrder("123")
fmt.Println(res.Order) // ShowOrderResponse.Order
Create order transaction (API docs)

Creates a new order transaction.

func (client *Config) CreateOrder(params CreateOrderParams) (*CreateOrderResponse, error)

res, _ := client.CreateOrder(taxjar.CreateOrderParams{
	TransactionID:   "123",
	TransactionDate: "2019/05/15",
	FromCountry:     "US",
	FromZip:         "94025",
	FromState:       "CA",
	FromCity:        "Menlo Park",
	FromStreet:      "2825 Sand Hill Rd",
	ToCountry:       "US",
	ToZip:           "94303",
	ToState:         "CA",
	ToCity:          "Palo Alto",
	ToStreet:        "5230 Newell Road",
	Amount:          267.9,
	Shipping:        0,
	SalesTax:        0,
	LineItems:       []taxjar.OrderLineItem{
		{
			ID:             "1",
			Quantity:       1,
			Description:    "Legal Services",
			ProductTaxCode: "19005",
			UnitPrice:      535.8,
			Discount:       267.9,
			SalesTax:       0,
		},
	},
})
fmt.Println(res.Order) // CreateOrderResponse.Order
Update order transaction (API docs)

Updates an existing order transaction created through the API.

func (client *Config) UpdateOrder(params UpdateOrderParams) (*UpdateOrderResponse, error)

res, _ := client.UpdateOrder(taxjar.UpdateOrderParams{
	TransactionID: "123",
	Amount:        283.6,
	Shipping:      5,
	SalesTax:      1.04,
	LineItems:     []taxjar.OrderLineItem{
		{
			ID:             "1",
			Quantity:       1,
			Description:    "Legal Services",
			ProductTaxCode: "19005",
			UnitPrice:      535.8,
			Discount:       267.9,
			SalesTax:       0,
		},
		{
			ID:          "2",
			Quantity:    2,
			Description: "Hoberman Switch Pitch",
			UnitPrice:   10.7,
			Discount:    10.7,
			SalesTax:    1.04,
		},
	},
})
fmt.Println(res.Order) // UpdateOrderResponse.Order
Delete order transaction (API docs)

Deletes an existing order transaction created through the API.

func (client *Config) DeleteOrder(transactionID string, params ...DeleteOrderParams) (*DeleteOrderResponse, error)

res, _ := client.DeleteOrder("123")
fmt.Println(res.Order) // DeleteOrderResponse.Order
List refund transactions (API docs)

Lists existing refund transactions created through the API.

func (client *Config) ListRefunds(params ListRefundsParams) (*ListRefundsResponse, error)

res, _ := client.ListRefunds(taxjar.ListRefundsParams{
	FromTransactionDate: "2015/05/01",
	ToTransactionDate:   "2015/05/31",
})
fmt.Println(res.Refunds) // ListRefundsResponse.Refunds
Show refund transaction (API docs)

Shows an existing refund transaction created through the API.

func (client *Config) ShowRefund(transactionID string, params ...ShowRefundParams) (*ShowRefundResponse, error)

res, _ := client.ShowRefund("321")
fmt.Println(res.Refund) // ShowRefundResponse.Refund
Create refund transaction (API docs)

Creates a new refund transaction.

func (client *Config) CreateRefund(params CreateRefundParams) (*CreateRefundResponse, error)

res, _ := client.CreateRefund(taxjar.CreateRefundParams{
	TransactionID:          "123-refund",
	TransactionReferenceID: "123",
	TransactionDate:        "2019/05/15",
	FromCountry:            "US",
	FromZip:                "94025",
	FromState:              "CA",
	FromCity:               "Menlo Park",
	FromStreet:             "2825 Sand Hill Rd",
	ToCountry:              "US",
	ToZip:                  "94303",
	ToState:                "CA",
	ToCity:                 "Palo Alto",
	ToStreet:               "5230 Newell Road",
	Amount:                 -5.35,
	Shipping:               -0,
	SalesTax:               -0.52,
	LineItems:              []taxjar.RefundLineItem{
		{
			ID:             "1",
			Quantity:       1,
			Description:    "Legal Services",
			ProductTaxCode: "19005",
			UnitPrice:      -0,
			Discount:       -0,
			SalesTax:       -0,
		},
		{
			ID:          "2",
			Quantity:    1,
			Description: "Hoberman Switch Pitch",
			UnitPrice:   -0,
			Discount:    -5.35,
			SalesTax:    -0.52,
		},
	},
})
fmt.Println(res.Refund) // CreateRefundResponse.Refund
Update refund transaction (API docs)

Updates an existing refund transaction created through the API.

func (client *Config) UpdateRefund(params UpdateRefundParams) (*UpdateRefundResponse, error)

res, _ := client.UpdateRefund(taxjar.UpdateRefundParams{
	TransactionID:          "123-refund",
	TransactionReferenceID: "123",
	Amount:                 -10.35,
	Shipping:               -5,
})
fmt.Println(res.Refund) // UpdateRefundResponse.Refund
Delete refund transaction (API docs)

Deletes an existing refund transaction created through the API.

func (client *Config) DeleteRefund(transactionID string, params ...DeleteRefundParams) (*DeleteRefundResponse, error)

res, _ := client.DeleteRefund("123-refund")
fmt.Println(res.Refund) // DeleteRefundResponse.Refund
List customers (API docs)

Lists existing customers created through the API.

func (client *Config) ListCustomers() (*ListCustomersResponse, error)

res, _ := client.ListCustomers()
fmt.Println(res.Customers) // ListCustomersResponse.Customers
Show customer (API docs)

Shows an existing customer created through the API.

func (client *Config) ShowCustomer(customerID string) (*ShowCustomerResponse, error)

res, _ := client.ShowCustomer("123")
fmt.Println(res.Customer) // ShowCustomerResponse.Customer
Create customer (API docs)

Creates a new customer.

func (client *Config) CreateCustomer(params CreateCustomerParams) (*CreateCustomerResponse, error)

res, _ := client.CreateCustomer(taxjar.CreateCustomerParams{
	CustomerID:    "123",
	ExemptionType: "wholesale",
	Name:          "Initech",
	ExemptRegions: []taxjar.ExemptRegion{
		{
			Country: "US",
			State:   "TX",
		},
	},
	Country: "US",
	State:   "TX",
	Zip:     "78744",
	City:    "Austin",
	Street:  "4120 Freidrich Lane",
})
fmt.Println(res.Customer) // CreateCustomerResponse.Customer
Update customer (API docs)

Updates an existing customer created through the API.

func (client *Config) UpdateCustomer(params UpdateCustomerParams) (*UpdateCustomerResponse, error)

res, _ := client.UpdateCustomer(taxjar.UpdateCustomerParams{
	CustomerID:    "123",
	ExemptionType: "non_exempt",
	Name:          "Initech",
	ExemptRegions: []taxjar.ExemptRegion{
		{
			Country: "US",
			State:   "MA",
		},
		{
			Country: "US",
			State:   "TX",
		},
	},
})
fmt.Println(res.Customer) // UpdateCustomerResponse.Customer
Delete customer (API docs)

Deletes an existing customer created through the API.

func (client *Config) DeleteCustomer(customerID string) (*DeleteCustomerResponse, error)

res, _ := client.DeleteCustomer("123")
fmt.Println(res.Customer) // DeleteCustomerResponse.Customer
List tax rates for a location (by zip/postal code) (API docs)

Shows the sales tax rates for a given location.

Please note this method only returns the full combined rate for a given location. It does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using TaxForOrder to accurately calculate sales tax for an order.

func (client *Config) RatesForLocation(zip string, params ...RatesForLocationParams) (*RatesForLocationResponse, error)

res, _ := client.RatesForLocation("90002")
fmt.Println(res.Rate) // RatesForLocationResponse.Rate
List nexus regions (API docs)

Lists existing nexus locations for a TaxJar account.

func (client *Config) NexusRegions() (*NexusRegionsResponse, error)

res, _ := client.NexusRegions()
fmt.Println(res.Regions) // NexusRegionsResponse.Regions
Validate an address (API docs)

Validates a customer address and returns back a collection of address matches. Address validation requires a TaxJar Plus subscription.

func (client *Config) ValidateAddress(params ValidateAddressParams) (*ValidateAddressResponse, error)

res, _ := client.ValidateAddress(taxjar.ValidateAddressParams{
	Country: "US",
	State:   "AZ",
	Zip:     "85297",
	City:    "Gilbert",
	Street:  "3301 South Greenfield Rd",
})
fmt.Println(res.Addresses) // ValidateAddressResponse.Addresses
Validate a VAT number (API docs)

Validates an existing VAT identification number against VIES.

func (client *Config) Validate(params ValidateParams) (*ValidateResponse, error)

res, _ := client.Validate({
	VAT: "FR40303265045",
})
fmt.Println(res.Validation) // ValidateResponse.Validation
Summarize tax rates for all regions (API docs)

Retrieve minimum and average sales tax rates by region as a backup.

This method is useful for periodically pulling down rates to use if the TaxJar API is unavailable. However, it does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using TaxForOrder to accurately calculate sales tax for an order.

func (client *Config) SummaryRates() (*SummaryRatesResponse, error)

res, _ := client.SummaryRates()
fmt.Println(res.SummaryRates) // SummaryRatesResponse.SummaryRates

Error Handling

res, err := client.TaxForOrder(taxjar.TaxForOrderParams{
	FromCountry: "US",
	FromZip:     "94025",
	FromState:   "CA",
	FromCity:    "Menlo Park",
	FromStreet:  "2825 Sand Hill Rd",
	ToCountry:   "US",
	ToZip:       "94303",
	ToState:     "CA",
	ToCity:      "Palo Alto",
	ToStreet:    "5230 Newell Road",
	Amount:      267.9,
	Shipping:    0,
	LineItems:   []taxjar.TaxLineItem{
		{
			ID:             "1",
			Quantity:       1,
			ProductTaxCode: "19005",
			UnitPrice:      535.8,
			Discount:       267.9,
		},
	},
})
if err != nil {
  fmt.Println(err) // taxjar: 401 Unauthorized - Not Authorized for route 'POST /v2/taxes'
} else {
  fmt.Println(res.Tax)
}
// or extract more information by asserting to `*taxjar.Error`
if err := err.(*taxjar.Error); err != nil {
	fmt.Println(err.Status) // 401
	fmt.Println(err.Err) // Unauthorized
	fmt.Println(err.Detail) // Not authorized for route `POST /v2/taxes'
	fmt.Printf("%+v", errors.Wrap(err, "")) // Stack trace:
	// taxjar: 401 Unauthorized - Not Authorized for route 'POST /v2/taxes'
	//
	// main.main
	//         /Path/to/your/file.go:292
	// runtime.main
	//         /usr/local/go/src/runtime/proc.go:200
	// runtime.goexit
	//         /usr/local/go/src/runtime/asm_amd64.s:1337
} else {
	fmt.Println(res.Tax)
}

Optional Configuration

To add additional headers to each request, assign them to client.Headers. For example, to test specific error response codes, pass the custom X-TJ-Expected-Response header:

client.Headers = map[string]interface{}{
	"X-TJ-Expected-Response": 422,
}

If you'd like to customize the timeout for requests, pass a time value to client.Timeout.

client.Timeout = 45 * time.Second // taxjar.DefaultTimeout: 30 * time.Second

To set more detailed timeouts, you may also pass a custom transport to client.Transport.

client.Transport = &http.Transport{
	DialContext: (&net.Dialer{
		Timeout:   20 * Time.Second,
		KeepAlive: 20 * Time.Second,
	}).DialContext,
	TLSHandshakeTimeout:   20 * time.Second,
	ExpectContinueTimeout: 8 * time.Second,
	ResponseHeaderTimeout: 6 * time.Second,
}

/* taxjar.DefaultTransport:
&http.Transport{
	DialContext: (&net.Dialer{
		Timeout:   10 * Time.Second,
		KeepAlive: 10 * Time.Second,
	}).DialContext,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 4 * time.Second,
	ResponseHeaderTimeout: 3 * time.Second,
}
*/

For even more customization, pass a custom *http.Client to client.HTTPClient.

client.HTTPClient = &http.Client{/* your configuration here */}

Sandbox Environment

You may also configure the client to use TaxJar's sandbox environment. The sandbox environment requires a TaxJar Plus subscription.

import "github.com/taxjar/taxjar-go"

// Instantiate client and set `APIURL`:
client := taxjar.NewClient(taxjar.Config{
	APIKey: os.Getenv("TAXJAR_SANDBOX_API_KEY"),
	APIURL: taxjar.SandboxAPIURL,
})

// or
client := taxjar.NewClient()
client.APIKey = os.Getenv("TAXJAR_SANDBOX_API_KEY")
client.APIURL = taxjar.SandboxAPIURL

Testing

make test

To validate API methods in the TaxJar sandbox environment, pass the following environment variables:

TAXJAR_API_URL="https://api.sandbox.taxjar.com" \
TAXJAR_API_KEY="9e0cd62a22f451701f29c3bde214" \
make test

Documentation

Overview

Package taxjar - Official Go API client from TaxJar (https://www.taxjar.com)

For more information, see our:

• Go Quickstart Guide (https://developers.taxjar.com/api/guides/go/)

• API docs (https://developers.taxjar.com/api/reference/?go)

• API Guides (https://developers.taxjar.com/api/guides)

• Integration Guides (https://developers.taxjar.com/integrations)

• README (https://github.com/taxjar/taxjar-go/blob/master/README.md)

Index

Examples

Constants

View Source
const DefaultAPIURL = "https://api.taxjar.com"

DefaultAPIURL ("https://api.taxjar.com") is the default base API URL for each request to TaxJar․

Override this by setting `Config.APIURL` to a different string․

View Source
const DefaultAPIVersion = "v2"

DefaultAPIVersion ("v2") is the default TaxJar API version․

Override this by setting `Config.APIVersion` to a different string․

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout for requests is `30 * time.Second`․

Override this by setting `Config.Timeout` to a different time value․

View Source
const SandboxAPIURL = "https://api.sandbox.taxjar.com"

SandboxAPIURL ("https://api.sandbox.taxjar.com") is the base API URL to send requests to TaxJar's sandbox environment․

Use by setting `Config.APIURL` to `taxjar.SandboxAPIURL`․

Please note that TaxJar's sandbox environment requires a TaxJar Plus account (https://www.taxjar.com/plus/)․

See https://developers.taxjar.com/api/reference/?go#sandbox-environment for more details․

Variables

View Source
var DefaultTransport = &http.Transport{
	DialContext: (&net.Dialer{
		Timeout:   10 * time.Second,
		KeepAlive: 10 * time.Second,
	}).DialContext,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 4 * time.Second,
	ResponseHeaderTimeout: 3 * time.Second,
}

DefaultTransport is the default `*http.Transport` for requests․

Override this by setting `Config.Transport` to a different `*http.Transport` (from net/http package - https://godoc.org/net/http#Transport)․

Functions

This section is empty.

Types

type Address

type Address struct {
	Country string `json:"country"`
	State   string `json:"state"`
	Zip     string `json:"zip"`
	City    string `json:"city"`
	Street  string `json:"street"`
}

Address is the structure for an address returned from `ValidateAddress` within `ValidateAddressResponse.Addresses`․

type Breakdown

type Breakdown struct {
	TaxableAmount                 float64             `json:"taxable_amount"`
	TaxCollectable                float64             `json:"tax_collectable"`
	CombinedTaxRate               float64             `json:"combined_tax_rate"`
	StateTaxableAmount            float64             `json:"state_taxable_amount"`
	StateTaxRate                  float64             `json:"state_tax_rate"`
	StateTaxCollectable           float64             `json:"state_tax_collectable"`
	CountyTaxableAmount           float64             `json:"county_taxable_amount"`
	CountyTaxRate                 float64             `json:"county_tax_rate"`
	CountyTaxCollectable          float64             `json:"county_tax_collectable"`
	CityTaxableAmount             float64             `json:"city_taxable_amount"`
	CityTaxRate                   float64             `json:"city_tax_rate"`
	CityTaxCollectable            float64             `json:"city_tax_collectable"`
	SpecialDistrictTaxableAmount  float64             `json:"special_district_taxable_amount"`
	SpecialTaxRate                float64             `json:"special_tax_rate"`
	SpecialDistrictTaxCollectable float64             `json:"special_district_tax_collectable"`
	Shipping                      Shipping            `json:"shipping"`
	LineItems                     []LineItemBreakdown `json:"line_items"`
	// Canada
	GSTTaxableAmount float64 `json:"gst_taxable_amount"`
	GSTTaxRate       float64 `json:"gst_tax_rate"`
	GST              float64 `json:"gst"`
	PSTTaxableAmount float64 `json:"pst_taxable_amount"`
	PSTTaxRate       float64 `json:"pst_tax_rate"`
	PST              float64 `json:"pst"`
	QSTTaxableAmount float64 `json:"qst_taxable_amount"`
	QSTTaxRate       float64 `json:"qst_tax_rate"`
	QST              float64 `json:"qst"`
	// Other International Attributes
	CountryTaxableAmount  float64 `json:"country_taxable_amount"`
	CountryTaxRate        float64 `json:"country_tax_rate"`
	CountryTaxCollectable float64 `json:"country_tax_collectable"`
}

Breakdown is the structure for `TaxForOrderResponse.Tax.Breakdown`․

type CategoriesResponse

type CategoriesResponse struct {
	Categories []Category `json:"categories"`
}

CategoriesResponse is the structure returned from `Categories`․

Access TaxJar's product tax categories with `CategoriesResponse.Categories`․

type Category

type Category struct {
	Name           string `json:"name"`
	ProductTaxCode string `json:"product_tax_code"`
	Description    string `json:"description"`
}

Category is the structure for a product tax category returned from `Categories` within `CategoriesResponse.Categories`․

type Config

type Config struct {
	APIURL     string // default: "https://api.taxjar.com"
	APIKey     string
	APIVersion string // default: "v2"
	Headers    map[string]interface{}
	HTTPClient *http.Client    // default: `&http.Client{}` (from net/http package - https://godoc.org/net/http#Client)
	Timeout    time.Duration   // default: `30 * time.Second`
	Transport  *http.Transport /* default:
	&http.Transport{
		DialContext: (&net.Dialer{
			Timeout:   10 * time.Second,
			KeepAlive: 10 * time.Second,
		}).DialContext,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 4 * time.Second,
		ResponseHeaderTimeout: 3 * time.Second,
	}*/
}

Config is the structure for configuring a `taxjar` client․ Pass a `Config` to `NewClient` to instantiate a client․

See below for default values․

func NewClient

func NewClient(config ...Config) Config

NewClient instantiates a new `taxjar` client․

Configure the client by passing a `Config` to `NewClient` or by setting configuration values such as `APIURL`, `APIKey`, `APIVersion`, `Headers`, `HTTPClient`, `Timeout`, and `Transport` after instantiation․

NewClient returns a client (type `Config`), on which you can call other methods to interact with TaxJar's API such as `Categories`, `TaxForOrder`, `CreateOrder`, etc․

See our Go Quickstart Guide for more usage details and background: https://developers.taxjar.com/api/guides/go/#go-quickstart

Example
// Configure during instantiation
client := taxjar.NewClient(taxjar.Config{
	APIKey: os.Getenv("TAXJAR_API_KEY"),
})

// Or configure after instantiation
client = taxjar.NewClient()
client.APIKey = os.Getenv("TAXJAR_API_KEY")
Output:

func (*Config) Categories

func (client *Config) Categories() (*CategoriesResponse, error)

Categories lists all TaxJar product tax categories to be used for products that are either exempt from sales tax in some jurisdictions or are taxed at reduced rates․

See https://developers.taxjar.com/api/reference/?go#categories for more details․

Example
res, err := client.Categories()
if err != nil {
	// handle error
}
fmt.Printf("Categories %+v", res.Categories)
Output:

func (*Config) CreateCustomer

func (client *Config) CreateCustomer(params CreateCustomerParams) (*CreateCustomerResponse, error)

CreateCustomer creates a new customer in TaxJar․ Use the newly created customer's `CustomerID` when calculating tax with `TaxForOrder` or when creating or updating transactions․

See https://developers.taxjar.com/api/reference/?go#post-create-a-customer for more details․

Example
res, err := client.CreateCustomer(taxjar.CreateCustomerParams{
	CustomerID:    "123",
	ExemptionType: "wholesale",
	Name:          "Initech",
	ExemptRegions: []taxjar.ExemptRegion{
		{
			Country: "US",
			State:   "TX",
		},
	},
	Country: "US",
	State:   "TX",
	Zip:     "78744",
	City:    "Austin",
	Street:  "4120 Freidrich Ln",
})
if err != nil {
	// handle error
}
fmt.Printf("CreateCustomer %+v", res.Customer)
Output:

func (*Config) CreateOrder

func (client *Config) CreateOrder(params CreateOrderParams) (*CreateOrderResponse, error)

CreateOrder creates a new order in TaxJar․

See https://developers.taxjar.com/api/reference/?go#post-create-an-order-transaction for more details․

Example
res, err := client.CreateOrder(taxjar.CreateOrderParams{
	TransactionID:   "13579-246810",
	TransactionDate: "2015/09/08",
	ToCountry:       "US",
	ToZip:           "10019",
	ToState:         "NY",
	ToCity:          "New York",
	ToStreet:        "1697 Broadway",
	Amount:          36.21,
	Shipping:        5,
	SalesTax:        0,
	LineItems: []taxjar.OrderLineItem{
		{
			ID:                "1",
			Quantity:          1,
			ProductIdentifier: "12-34243-9",
			Description:       "Fuzzy Sweater",
			ProductTaxCode:    "20010",
			UnitPrice:         36.72,
			Discount:          5.51,
			SalesTax:          0,
		},
	},
})
if err != nil {
	// handle error
}
fmt.Printf("CreateOrder %+v", res.Order)
Output:

func (*Config) CreateRefund

func (client *Config) CreateRefund(params CreateRefundParams) (*CreateRefundResponse, error)

CreateRefund creates a new refund in TaxJar․

See https://developers.taxjar.com/api/reference/?go#post-create-a-refund-transaction for more details․

Example
res, err := client.CreateRefund(taxjar.CreateRefundParams{
	TransactionID:          "13579-246810-refund",
	TransactionReferenceID: "13579-246810",
	TransactionDate:        "2015/09/08",
	ToCountry:              "US",
	ToZip:                  "10019",
	ToState:                "NY",
	ToCity:                 "New York",
	ToStreet:               "1697 Broadway",
	Amount:                 -116.51,
	Shipping:               -0,
	SalesTax:               -10.74,
	LineItems: []taxjar.RefundLineItem{
		{
			ID:                "1",
			Quantity:          1,
			ProductIdentifier: "12-34243-9",
			Description:       "Fuzzy Sweater",
			ProductTaxCode:    "20010",
			UnitPrice:         -0,
			Discount:          -0,
			SalesTax:          -0,
		},
		{
			ID:                "2",
			Quantity:          1,
			ProductIdentifier: "12-34245-8",
			Description:       "TaxJar Designer T-shirt",
			ProductTaxCode:    "20010",
			UnitPrice:         -111,
			SalesTax:          -9.85,
		},
	},
})
if err != nil {
	// handle error
}
fmt.Printf("CreateRefund %+v", res.Refund)
Output:

func (*Config) DeleteCustomer

func (client *Config) DeleteCustomer(customerID string) (*DeleteCustomerResponse, error)

DeleteCustomer deletes a customer in TaxJar․

See https://developers.taxjar.com/api/reference/?go#delete-delete-a-customer for more details․

Example
res, err := client.DeleteCustomer("123")
if err != nil {
	// handle error
}
fmt.Printf("DeleteCustomer %+v", res.Customer)
Output:

func (*Config) DeleteOrder

func (client *Config) DeleteOrder(transactionID string, params ...DeleteOrderParams) (*DeleteOrderResponse, error)

DeleteOrder deletes an order in TaxJar․

See https://developers.taxjar.com/api/reference/?go#delete-delete-an-order-transaction for more details․

Example
res, err := client.DeleteOrder("13579-246810")
if err != nil {
	fmt.Println(err)
}
fmt.Printf("DeleteOrder %+v", res.Order)
Output:

func (*Config) DeleteRefund

func (client *Config) DeleteRefund(transactionID string, params ...DeleteRefundParams) (*DeleteRefundResponse, error)

DeleteRefund deletes a refund in TaxJar․

See https://developers.taxjar.com/api/reference/?go#delete-delete-a-refund-transaction for more details․

Example
res, err := client.DeleteRefund("13579-246810-refund")
if err != nil {
	// handle error
}
fmt.Printf("DeleteRefund %+v", res.Refund)
Output:

func (*Config) ListCustomers

func (client *Config) ListCustomers() (*ListCustomersResponse, error)

ListCustomers lists existing customer IDs in TaxJar․

See https://developers.taxjar.com/api/reference/?go#get-list-customers for more details․

Example
res, err := client.ListCustomers()
if err != nil {
	// handle error
}
fmt.Printf("ListCustomers %+v", res.Customers)
Output:

func (*Config) ListOrders

func (client *Config) ListOrders(params ListOrdersParams) (*ListOrdersResponse, error)

ListOrders lists existing order IDs in TaxJar․

See https://developers.taxjar.com/api/reference/?go#get-list-order-transactions for more details․

Example
res, err := client.ListOrders(taxjar.ListOrdersParams{
	FromTransactionDate: "2015/09/01",
	ToTransactionDate:   "2015/09/30",
})
if err != nil {
	fmt.Println(err)
}
fmt.Printf("ListOrders %+v", res.Orders)
Output:

func (*Config) ListRefunds

func (client *Config) ListRefunds(params ListRefundsParams) (*ListRefundsResponse, error)

ListRefunds lists existing refund IDs in TaxJar․

See https://developers.taxjar.com/api/reference/?go#get-list-refund-transactions for more details․

Example
res, err := client.ListRefunds(taxjar.ListRefundsParams{
	FromTransactionDate: "2015/09/01",
	ToTransactionDate:   "2015/09/30",
})
if err != nil {
	// handle error
}
fmt.Printf("ListRefunds %+v", res.Refunds)
Output:

func (*Config) NexusRegions

func (client *Config) NexusRegions() (*NexusRegionsResponse, error)

NexusRegions lists existing nexus locations for a TaxJar account․

See https://developers.taxjar.com/api/reference/?go#get-list-nexus-regions for more details․

Example
res, err := client.NexusRegions()
if err != nil {
	// handle error
}
fmt.Printf("NexusRegions %+v", res.Regions)
Output:

func (*Config) RatesForLocation

func (client *Config) RatesForLocation(zip string, params ...RatesForLocationParams) (*RatesForLocationResponse, error)

RatesForLocation shows the sales tax rates for a given location․

Please note `RatesForLocation` only returns the full combined rate for a given location․ It does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays․

We recommend using `TaxForOrder` to accurately calculate sales tax for an order․

See https://developers.taxjar.com/api/reference/?go#get-show-tax-rates-for-a-location for more details.

Example
res, err := client.RatesForLocation("94043", taxjar.RatesForLocationParams{
	Country: "US",
	State:   "CA",
	City:    "Mountain View",
	Street:  "311 Moffett Blvd",
})
if err != nil {
	// handle error
}
fmt.Printf("RatesForLocation %+v", res.Rate)
Output:

func (*Config) ShowCustomer

func (client *Config) ShowCustomer(customerID string) (*ShowCustomerResponse, error)

ShowCustomer shows an existing customer in TaxJar․

See https://developers.taxjar.com/api/reference/?go#get-show-a-customer for more details․

Example
res, err := client.ShowCustomer("123")
if err != nil {
	// handle error
}
fmt.Printf("ShowCustomer %+v", res.Customer)
Output:

func (*Config) ShowOrder

func (client *Config) ShowOrder(transactionID string, params ...ShowOrderParams) (*ShowOrderResponse, error)

ShowOrder shows an existing order in TaxJar․

See https://developers.taxjar.com/api/reference/?go#get-show-an-order-transaction for more details․

Example
res, err := client.ShowOrder("13579-246810")
if err != nil {
	// handle error
}
fmt.Printf("ShowOrder %+v", res.Order)
Output:

func (*Config) ShowRefund

func (client *Config) ShowRefund(transactionID string, params ...ShowRefundParams) (*ShowRefundResponse, error)

ShowRefund shows an existing refund in TaxJar․

See https://developers.taxjar.com/api/reference/?go#get-show-a-refund-transaction for more details․

Example
res, err := client.ShowRefund("13579-246810-refund")
if err != nil {
	// handle error
}
fmt.Printf("ShowRefund %+v", res.Refund)
Output:

func (*Config) SummaryRates

func (client *Config) SummaryRates() (*SummaryRatesResponse, error)

SummaryRates retrieves minimum and average sales tax rates by region, which you can use as a backup․

See https://developers.taxjar.com/api/reference/?go#get-summarize-tax-rates-for-all-regions for more details․

Example
res, err := client.SummaryRates()
if err != nil {
	// handle error
}
fmt.Printf("SummaryRates %+v", res.SummaryRates)
Output:

func (*Config) TaxForOrder

func (client *Config) TaxForOrder(params TaxForOrderParams) (*TaxForOrderResponse, error)

TaxForOrder shows the sales tax that should be collected for a given order․

See https://developers.taxjar.com/api/reference/?go#post-calculate-sales-tax-for-an-order for more details․

Example
res, err := client.TaxForOrder(taxjar.TaxForOrderParams{
	FromCountry: "US",
	FromZip:     "92093",
	FromState:   "CA",
	FromCity:    "La Jolla",
	FromStreet:  "9500 Gilman Drive",
	ToCountry:   "US",
	ToZip:       "90002",
	ToState:     "CA",
	ToCity:      "Los Angeles",
	ToStreet:    "1335 E 103rd St",
	Amount:      15,
	Shipping:    1.5,
	LineItems: []taxjar.TaxLineItem{
		{
			ID:             "1",
			Quantity:       1,
			ProductTaxCode: "20010",
			UnitPrice:      15,
			Discount:       0,
		},
	},
})
if err != nil {
	// handle error
}
fmt.Printf("TaxForOrder %+v", res.Tax)
Output:

func (*Config) UpdateCustomer

func (client *Config) UpdateCustomer(params UpdateCustomerParams) (*UpdateCustomerResponse, error)

UpdateCustomer updates an existing customer in TaxJar․

Use the updated customer's `CustomerID` when calculating tax with TaxForOrder or when creating or updating transactions․

See https://developers.taxjar.com/api/reference/?go#put-update-a-customer for more details․

Example
res, err := client.UpdateCustomer(taxjar.UpdateCustomerParams{
	CustomerID:    "123",
	ExemptionType: "non_exempt",
	Name:          "Initech",
})
if err != nil {
	fmt.Println(err)
}
fmt.Printf("UpdateCustomer %+v", res.Customer)
Output:

func (*Config) UpdateOrder

func (client *Config) UpdateOrder(params UpdateOrderParams) (*UpdateOrderResponse, error)

UpdateOrder updates an existing order in TaxJar․

See https://developers.taxjar.com/api/reference/?go#put-update-an-order-transaction for more details․

Example
res, err := client.UpdateOrder(taxjar.UpdateOrderParams{
	TransactionID: "13579-246810",
	Amount:        152.72,
	Shipping:      10,
	SalesTax:      10.74,
	LineItems: []taxjar.OrderLineItem{
		{
			ID:                "1",
			Quantity:          1,
			ProductIdentifier: "12-34243-9",
			Description:       "Fuzzy Sweater",
			ProductTaxCode:    "20010",
			UnitPrice:         36.72,
			Discount:          5.51,
			SalesTax:          0,
		},
		{
			ID:                "2",
			Quantity:          1,
			ProductIdentifier: "12-34245-8",
			Description:       "TaxJar Designer T-shirt",
			ProductTaxCode:    "20010",
			UnitPrice:         111,
			SalesTax:          9.85,
		},
	},
})
if err != nil {
	// handle error
}
fmt.Printf("UpdateOrder %+v", res.Order)
Output:

func (*Config) UpdateRefund

func (client *Config) UpdateRefund(params UpdateRefundParams) (*UpdateRefundResponse, error)

UpdateRefund updates an existing refund in TaxJar․

See https://developers.taxjar.com/api/reference/?go#put-update-a-refund-transaction for more details․

Example
res, err := client.UpdateRefund(taxjar.UpdateRefundParams{
	TransactionID:          "13579-246810-refund",
	TransactionReferenceID: "13579-246810",
	Shipping:               -5,
})
if err != nil {
	// handle error
}
fmt.Printf("UpdateRefund %+v", res.Refund)
Output:

func (*Config) Validate

func (client *Config) Validate(params ValidateParams) (*ValidateResponse, error)

Validate validates a VAT identification number with VIES (http://ec.europa.eu/taxation_customs/vies/)․

See https://developers.taxjar.com/api/reference/?go#get-validate-a-vat-number for more details․

Example
res, err := client.Validate(taxjar.ValidateParams{
	VAT: "FR40303265045",
})
if err != nil {
	// handle error
}
fmt.Printf("Validate %+v", res.Validation)
Output:

func (*Config) ValidateAddress

func (client *Config) ValidateAddress(params ValidateAddressParams) (*ValidateAddressResponse, error)

ValidateAddress validates a customer address and returns back a collection of address matches․

Address validation requires a TaxJar Plus subscription (https://www.taxjar.com/plus/)․

See https://developers.taxjar.com/api/reference/?go#post-validate-an-address for more details․

Example
res, err := client.ValidateAddress(taxjar.ValidateAddressParams{
	Country: "US",
	State:   "AZ",
	Zip:     "85297",
	City:    "Gilbert",
	Street:  "3301 South Greenfield Rd",
})
if err != nil {
	// handle error
}
fmt.Printf("ValidateAddress %+v", res.Addresses)
Output:

type CreateCustomerParams

type CreateCustomerParams struct {
	CustomerID    string         `json:"customer_id,omitempty"`
	ExemptionType string         `json:"exemption_type,omitempty"`
	Name          string         `json:"name,omitempty"`
	ExemptRegions []ExemptRegion `json:"exempt_regions,omitempty"`
	Country       string         `json:"country,omitempty"`
	State         string         `json:"state,omitempty"`
	Zip           string         `json:"zip,omitempty"`
	City          string         `json:"city,omitempty"`
	Street        string         `json:"street,omitempty"`
}

CreateCustomerParams should be passed to `CreateCustomer` to create a customer․

type CreateCustomerResponse

type CreateCustomerResponse struct {
	Customer Customer `json:"customer"`
}

CreateCustomerResponse is the structure returned from `CreateCustomer`․

Access the created customer with `CreateCustomerResponse.Customer`․

type CreateOrderParams

type CreateOrderParams struct {
	TransactionID   string          `json:"transaction_id,omitempty"`
	TransactionDate string          `json:"transaction_date,omitempty"`
	Provider        string          `json:"provider,omitempty"`
	FromCountry     string          `json:"from_country,omitempty"`
	FromZip         string          `json:"from_zip,omitempty"`
	FromState       string          `json:"from_state,omitempty"`
	FromCity        string          `json:"from_city,omitempty"`
	FromStreet      string          `json:"from_street,omitempty"`
	ToCountry       string          `json:"to_country,omitempty"`
	ToZip           string          `json:"to_zip,omitempty"`
	ToState         string          `json:"to_state,omitempty"`
	ToCity          string          `json:"to_city,omitempty"`
	ToStreet        string          `json:"to_street,omitempty"`
	Amount          float64         `json:"amount"`
	Shipping        float64         `json:"shipping"`
	SalesTax        float64         `json:"sales_tax"`
	CustomerID      string          `json:"customer_id,omitempty"`
	ExemptionType   string          `json:"exemption_type,omitempty"`
	LineItems       []OrderLineItem `json:"line_items,omitempty"`
}

CreateOrderParams should be passed to `CreateOrder` to create an order․

type CreateOrderResponse

type CreateOrderResponse struct {
	Order Order `json:"order"`
}

CreateOrderResponse is the structure returned from `CreateOrder`․

Access the created order with `CreateOrderResponse.Order`․

type CreateRefundParams

type CreateRefundParams struct {
	TransactionID          string           `json:"transaction_id,omitempty"`
	TransactionReferenceID string           `json:"transaction_reference_id,omitempty"`
	TransactionDate        string           `json:"transaction_date,omitempty"`
	Provider               string           `json:"provider,omitempty"`
	FromCountry            string           `json:"from_country,omitempty"`
	FromZip                string           `json:"from_zip,omitempty"`
	FromState              string           `json:"from_state,omitempty"`
	FromCity               string           `json:"from_city,omitempty"`
	FromStreet             string           `json:"from_street,omitempty"`
	ToCountry              string           `json:"to_country,omitempty"`
	ToZip                  string           `json:"to_zip,omitempty"`
	ToState                string           `json:"to_state,omitempty"`
	ToCity                 string           `json:"to_city,omitempty"`
	ToStreet               string           `json:"to_street,omitempty"`
	Amount                 float64          `json:"amount"`
	Shipping               float64          `json:"shipping"`
	SalesTax               float64          `json:"sales_tax"`
	CustomerID             string           `json:"customer_id,omitempty"`
	ExemptionType          string           `json:"exemption_type,omitempty"`
	LineItems              []RefundLineItem `json:"line_items,omitempty"`
}

CreateRefundParams should be passed to `CreateRefund` to create a refund․

type CreateRefundResponse

type CreateRefundResponse struct {
	Refund Refund `json:"refund"`
}

CreateRefundResponse is the structure returned from `CreateRefund`․

Access the created refund with `CreateRefundResponse.Refund`․

type Customer

type Customer struct {
	CustomerID    string         `json:"customer_id"`
	ExemptionType string         `json:"exemption_type"`
	ExemptRegions []ExemptRegion `json:"exempt_regions"`
	Name          string         `json:"name"`
	Country       string         `json:"country"`
	State         string         `json:"state"`
	Zip           string         `json:"zip"`
	City          string         `json:"city"`
	Street        string         `json:"street"`
}

Customer is the structure for a customer returned within `CreateCustomerResponse`, `UpdateCustomerResponse`, `ShowCustomerResponse`, and `DeleteCustomerResponse`․

type DeleteCustomerResponse

type DeleteCustomerResponse struct {
	CreateCustomerResponse
}

DeleteCustomerResponse is the structure returned from `DeleteCustomer`․

Access the deleted customer with `DeleteCustomerResponse.Customer`․

type DeleteOrderParams

type DeleteOrderParams struct {
	Provider string `url:"provider,omitempty"`
}

DeleteOrderParams should be passed to `DeleteOrder` to delete an order․

type DeleteOrderResponse

type DeleteOrderResponse struct {
	Order Order `json:"order"`
}

DeleteOrderResponse is the structure returned from `DeleteOrder`․

Access the deleted order with `DeleteOrderResponse.Order`․

type DeleteRefundParams

type DeleteRefundParams struct {
	Provider string `url:"provider,omitempty"`
}

DeleteRefundParams should be passed to `DeleteRefund` to delete a refund․

type DeleteRefundResponse

type DeleteRefundResponse struct {
	Refund Refund `json:"refund"`
}

DeleteRefundResponse is the structure returned from `DeleteRefund`․

Access the deleted refund with `DeleteRefundResponse.Refund`․

type Error

type Error struct {
	Err    string `json:"error"`
	Detail string `json:"detail"`
	Status int    `json:"status"`
}

Error is the custom error type returned in the second return value of each TaxJar API method (e.g., `TaxForOrder`)․

See here for example error handling that extracts `Err`, `Detail`, and `Status` fields and displays a stack trace: https://github.com/taxjar/taxjar-go/blob/master/README.md#error-handling

Example
client := taxjar.NewClient(taxjar.Config{
	APIKey: "INVALID_API_KEY",
})
res, err := client.TaxForOrder(taxjar.TaxForOrderParams{
	FromCountry: "US",
	FromZip:     "94025",
	FromState:   "CA",
	FromCity:    "Menlo Park",
	FromStreet:  "2825 Sand Hill Rd",
	ToCountry:   "US",
	ToZip:       "94303",
	ToState:     "CA",
	ToCity:      "Palo Alto",
	ToStreet:    "5230 Newell Road",
	Amount:      267.9,
	Shipping:    0,
	LineItems: []taxjar.TaxLineItem{
		{
			ID:             "1",
			Quantity:       1,
			ProductTaxCode: "19005",
			UnitPrice:      535.8,
			Discount:       267.9,
		},
	},
})
if err != nil {
	fmt.Println(err) // taxjar: 401 Unauthorized - Not Authorized for route 'POST /v2/taxes'
} else {
	fmt.Println(res.Tax)
}
// or extract more information by asserting to `*taxjar.Error`
if err := err.(*taxjar.Error); err != nil {
	fmt.Println(err.Status)                 // 401
	fmt.Println(err.Err)                    // Unauthorized
	fmt.Println(err.Detail)                 // Not authorized for route `POST /v2/taxes'
	fmt.Printf("%+v", errors.Wrap(err, "")) // Stack trace:
	// taxjar: 401 Unauthorized - Not Authorized for route 'POST /v2/taxes'
	//
	// main.main
	//         /Path/to/your/file.go:292
	// runtime.main
	//         /usr/local/go/src/runtime/proc.go:200
	// runtime.goexit
	//         /usr/local/go/src/runtime/asm_amd64.s:1337
} else {
	fmt.Println(res.Tax)
}
Output:

func (*Error) Error

func (err *Error) Error() string

type ExemptRegion

type ExemptRegion struct {
	Country string `json:"country,omitempty"`
	State   string `json:"state,omitempty"`
}

ExemptRegion is the structure for a customer exempt region passed within `CreateCustomerParams.ExemptRegions` and returned in `CreateCustomerResponse.Customer.ExemptRegions`․

type Jurisdictions

type Jurisdictions struct {
	Country string `json:"country"`
	State   string `json:"state"`
	County  string `json:"county"`
	City    string `json:"city"`
}

Jurisdictions is the structure for `TaxForOrderResponse.Tax.Jurisdictions`․

type LineItemBreakdown

type LineItemBreakdown struct {
	ID                           string  `json:"id"`
	TaxableAmount                float64 `json:"taxable_amount"`
	TaxCollectable               float64 `json:"tax_collectable"`
	CombinedTaxRate              float64 `json:"combined_tax_rate"`
	StateTaxableAmount           float64 `json:"state_taxable_amount"`
	StateSalesTaxRate            float64 `json:"state_sales_tax_rate"`
	StateAmount                  float64 `json:"state_amount"`
	CountyTaxableAmount          float64 `json:"county_taxable_amount"`
	CountyTaxRate                float64 `json:"county_tax_rate"`
	CountyAmount                 float64 `json:"county_amount"`
	CityTaxableAmount            float64 `json:"city_taxable_amount"`
	CityTaxRate                  float64 `json:"city_tax_rate"`
	CityAmount                   float64 `json:"city_amount"`
	SpecialDistrictTaxableAmount float64 `json:"special_district_taxable_amount"`
	SpecialTaxRate               float64 `json:"special_tax_rate"`
	SpecialDistrictAmount        float64 `json:"special_district_amount"`
	// Canada
	GSTTaxableAmount float64 `json:"gst_taxable_amount"`
	GSTTaxRate       float64 `json:"gst_tax_rate"`
	GST              float64 `json:"gst"`
	PSTTaxableAmount float64 `json:"pst_taxable_amount"`
	PSTTaxRate       float64 `json:"pst_tax_rate"`
	PST              float64 `json:"pst"`
	QSTTaxableAmount float64 `json:"qst_taxable_amount"`
	QSTTaxRate       float64 `json:"qst_tax_rate"`
	QST              float64 `json:"qst"`
	// Other International Attributes
	CountryTaxableAmount  float64 `json:"country_taxable_amount"`
	CountryTaxRate        float64 `json:"country_tax_rate"`
	CountryTaxCollectable float64 `json:"country_tax_collectable"`
}

LineItemBreakdown is the structure for a line item in `TaxForOrderResponse.Tax.Breakdown.LineItems`․

type ListCustomersResponse

type ListCustomersResponse struct {
	Customers []string `json:"customers"`
}

ListCustomersResponse is the structure returned from `ListCustomers`․

Access the customer list with `ListCustomersResponse.Customers`․

type ListOrdersParams

type ListOrdersParams struct {
	TransactionDate     string `url:"transaction_date,omitempty"`
	FromTransactionDate string `url:"from_transaction_date,omitempty"`
	ToTransactionDate   string `url:"to_transaction_date,omitempty"`
	Provider            string `url:"provider,omitempty"`
}

ListOrdersParams should be passed to `ListOrders` to list existing order IDs․

type ListOrdersResponse

type ListOrdersResponse struct {
	Orders []string `json:"orders"`
}

ListOrdersResponse is the structure returned from `ListOrders`․

Access the order list with `ListOrdersResponse.Orders`․

type ListRefundsParams

type ListRefundsParams struct {
	TransactionDate     string `url:"transaction_date,omitempty"`
	FromTransactionDate string `url:"from_transaction_date,omitempty"`
	ToTransactionDate   string `url:"to_transaction_date,omitempty"`
	Provider            string `url:"provider,omitempty"`
}

ListRefundsParams should be passed to `ListRefunds` to list existing refund IDs․

type ListRefundsResponse

type ListRefundsResponse struct {
	Refunds []string `json:"refunds"`
}

ListRefundsResponse is the structure returned from `ListRefunds`․

Access the refund list with `ListRefundsResponse.Refunds`․

type NexusAddress

type NexusAddress struct {
	ID      string `json:"id,omitempty"`
	Country string `json:"country,omitempty"`
	Zip     string `json:"zip,omitempty"`
	State   string `json:"state,omitempty"`
	City    string `json:"city,omitempty"`
	Street  string `json:"street,omitempty"`
}

NexusAddress is the structure for a nexus address passed within `TaxForOrderParams.NexusAddresses`․

type NexusRegion

type NexusRegion struct {
	CountryCode string `json:"country_code"`
	Country     string `json:"country"`
	RegionCode  string `json:"region_code"`
	Region      string `json:"region"`
}

NexusRegion is the structure for a nexus region returned within `NexusRegionsResponse.Regions`․

type NexusRegionsResponse

type NexusRegionsResponse struct {
	Regions []NexusRegion `json:"regions"`
}

NexusRegionsResponse is the structure returned from `NexusRegions`․

Access the nexus list with `NexusRegionsResponse.Regions`.

type Order

type Order struct {
	TransactionID          string          `json:"transaction_id"`
	UserID                 int             `json:"user_id"`
	TransactionDate        string          `json:"transaction_date"`
	TransactionReferenceID string          `json:"transaction_reference_id"`
	Provider               string          `json:"provider"`
	ExemptionType          string          `json:"exemption_type,omitempty"`
	FromCountry            string          `json:"from_country"`
	FromZip                string          `json:"from_zip"`
	FromState              string          `json:"from_state"`
	FromCity               string          `json:"from_city"`
	FromStreet             string          `json:"from_street"`
	ToCountry              string          `json:"to_country"`
	ToZip                  string          `json:"to_zip"`
	ToState                string          `json:"to_state"`
	ToCity                 string          `json:"to_city"`
	ToStreet               string          `json:"to_street"`
	Amount                 float64         `json:"amount,string"`
	Shipping               float64         `json:"shipping,string"`
	SalesTax               float64         `json:"sales_tax,string"`
	LineItems              []OrderLineItem `json:"line_items"`
}

Order is the structure for an order returned within `CreateOrderResponse`, `ShowOrderResponse`, `UpdateOrderResponse`, and `DeleteOrderResponse`․

type OrderLineItem

type OrderLineItem struct {
	ID                json.Number `json:"id,omitempty"`
	Quantity          int         `json:"quantity,omitempty"`
	ProductIdentifier string      `json:"product_identifier,omitempty"`
	Description       string      `json:"description,omitempty"`
	ProductTaxCode    string      `json:"product_tax_code,omitempty"`
	UnitPrice         float64     `json:"unit_price,omitempty,string"`
	Discount          float64     `json:"discount,omitempty,string"`
	SalesTax          float64     `json:"sales_tax,omitempty,string"`
}

OrderLineItem is the structure for a line item passed within `CreateOrderParams.LineItems` and `UpdateOrderParams.LineItems`․

OrderLineItem is also the structure for a line item returned within `CreateOrderResponse.Order.LineItems`, `UpdateOrderResponse.Order.LineItems`, `ShowOrderResponse.Order.LineItems`, and `DeleteOrderResponse.Order.LineItems`․

type Rate

type Rate struct {
	Zip                   string  `json:"zip"`
	Country               string  `json:"country"`
	Name                  string  `json:"name"`
	StandardRate          float64 `json:"standard_rate,string"`
	ReducedRate           float64 `json:"reduced_rate,string"`
	SuperReducedRate      float64 `json:"super_reduced_rate,string"`
	ParkingRate           float64 `json:"parking_rate,string"`
	DistanceSaleThreshold float64 `json:"distance_sale_threshold,string"`
	CountryRate           float64 `json:"country_rate,string"`
	State                 string  `json:"state"`
	StateRate             float64 `json:"state_rate,string"`
	County                string  `json:"county"`
	CountyRate            float64 `json:"county_rate,string"`
	City                  string  `json:"city"`
	CityRate              float64 `json:"city_rate,string"`
	CombinedDistrictRate  float64 `json:"combined_district_rate,string"`
	CombinedRate          float64 `json:"combined_rate,string"`
	FreightTaxable        bool    `json:"freight_taxable"`
}

Rate is the structure for a given location's sales tax rates․

type RatesForLocationParams

type RatesForLocationParams struct {
	Country string `url:"country,omitempty"`
	State   string `url:"state,omitempty"`
	City    string `url:"city,omitempty"`
	Street  string `url:"street,omitempty"`
}

RatesForLocationParams should be passed to `RatesForLocation` to show the sales tax rates for a given location․

type RatesForLocationResponse

type RatesForLocationResponse struct {
	Rate Rate `json:"rate"`
}

RatesForLocationResponse is the structure returned from `RatesForLocation`․

Access the location's rates with `RatesForLocationResponse.Rate`․

type Refund

type Refund struct {
	Order
}

Refund is the structure for a refund returned within `CreateRefundResponse`, `ShowRefundResponse`, `UpdateRefundResponse`, and `DeleteRefundResponse`․

type RefundLineItem

type RefundLineItem struct {
	ID                string  `json:"id,omitempty"`
	Quantity          int     `json:"quantity,omitempty"`
	ProductIdentifier string  `json:"product_identifier,omitempty"`
	Description       string  `json:"description,omitempty"`
	ProductTaxCode    string  `json:"product_tax_code,omitempty"`
	UnitPrice         float64 `json:"unit_price,omitempty"`
	Discount          float64 `json:"discount,omitempty"`
	SalesTax          float64 `json:"sales_tax,omitempty"`
}

RefundLineItem is the structure for a line item passed within `CreateRefundParams.LineItems` and `UpdateRefundParams.LineItems`․

RefundLineItem is also the structure for a line item returned within `CreateRefundResponse.Refund.LineItems`, `UpdateRefundResponse.Refund.LineItems`, `ShowRefundResponse.Refund.LineItems`, and `DeleteRefundResponse.Refund.LineItems`․

type Shipping

type Shipping struct {
	TaxableAmount         float64 `json:"taxable_amount"`
	TaxCollectable        float64 `json:"tax_collectable"`
	CombinedTaxRate       float64 `json:"combined_tax_rate"`
	StateTaxableAmount    float64 `json:"state_taxable_amount"`
	StateSalesTaxRate     float64 `json:"state_sales_tax_rate"`
	StateAmount           float64 `json:"state_amount"`
	CountyTaxableAmount   float64 `json:"county_taxable_amount"`
	CountyTaxRate         float64 `json:"county_tax_rate"`
	CountyAmount          float64 `json:"county_amount"`
	CityTaxableAmount     float64 `json:"city_taxable_amount"`
	CityTaxRate           float64 `json:"city_tax_rate"`
	CityAmount            float64 `json:"city_amount"`
	SpecialTaxableAmount  float64 `json:"special_taxable_amount"`
	SpecialTaxRate        float64 `json:"special_tax_rate"`
	SpecialDistrictAmount float64 `json:"special_district_amount"`
	// Canada
	GSTTaxableAmount float64 `json:"gst_taxable_amount"`
	GSTTaxRate       float64 `json:"gst_tax_rate"`
	GST              float64 `json:"gst"`
	PSTTaxableAmount float64 `json:"pst_taxable_amount"`
	PSTTaxRate       float64 `json:"pst_tax_rate"`
	PST              float64 `json:"pst"`
	QSTTaxableAmount float64 `json:"qst_taxable_amount"`
	QSTTaxRate       float64 `json:"qst_tax_rate"`
	QST              float64 `json:"qst"`
	// Other International Attributes
	CountryTaxableAmount  float64 `json:"country_taxable_amount"`
	CountryTaxRate        float64 `json:"country_tax_rate"`
	CountryTaxCollectable float64 `json:"country_tax_collectable"`
}

Shipping is the structure for `TaxForOrderResponse.Tax.Breakdown.Shipping`․

type ShowCustomerResponse

type ShowCustomerResponse struct {
	CreateCustomerResponse
}

ShowCustomerResponse is the structure returned from `ShowCustomer`․

Access the customer with `ShowCustomerResponse.Customer`․

type ShowOrderParams

type ShowOrderParams struct {
	Provider string `url:"provider,omitempty"`
}

ShowOrderParams should be passed to `ShowOrder` to show an order․

type ShowOrderResponse

type ShowOrderResponse struct {
	Order Order `json:"order"`
}

ShowOrderResponse is the structure returned from `ShowOrder`․

Access the order with `ShowOrderResponse.Order`․

type ShowRefundParams

type ShowRefundParams struct {
	Provider string `url:"provider,omitempty"`
}

ShowRefundParams should be passed to `ShowRefund` to show a refund․

type ShowRefundResponse

type ShowRefundResponse struct {
	Refund Refund `json:"refund"`
}

ShowRefundResponse is the structure returned from `ShowRefund`․

Access the refund with `ShowRefundResponse.Refund`․

type SummaryRate

type SummaryRate struct {
	CountryCode string `json:"country_code"`
	Country     string `json:"country"`
	RegionCode  string `json:"region_code"`
	Region      string `json:"region"`
	MinimumRate struct {
		Label string  `json:"label"`
		Rate  float64 `json:"rate"`
	} `json:"minimum_rate"`
	AverageRate struct {
		Label string  `json:"label"`
		Rate  float64 `json:"rate"`
	} `json:"average_rate"`
}

SummaryRate is the structure for a location's summarized (minimum and average) backup rates returned within `SummaryRatesResponse.SummaryRates`․

type SummaryRatesResponse

type SummaryRatesResponse struct {
	SummaryRates []SummaryRate `json:"summary_rates"`
}

SummaryRatesResponse is the structure returned from `SummaryRates`․

Access the summarized (minimum and average) backup rates with `SummaryRatesResponse.SummaryRates`.

type Tax

type Tax struct {
	OrderTotalAmount float64       `json:"order_total_amount"`
	Shipping         float64       `json:"shipping"`
	TaxableAmount    float64       `json:"taxable_amount"`
	AmountToCollect  float64       `json:"amount_to_collect"`
	Rate             float64       `json:"rate"`
	HasNexus         bool          `json:"has_nexus"`
	FreightTaxable   bool          `json:"freight_taxable"`
	TaxSource        string        `json:"tax_source"`
	ExemptionType    string        `json:"exemption_type"`
	Jurisdictions    Jurisdictions `json:"jurisdictions"`
	Breakdown        Breakdown     `json:"breakdown"`
}

Tax is the stucture for a tax calculation returned within `TaxForOrderResponse`․

type TaxForOrderParams

type TaxForOrderParams struct {
	FromCountry    string         `json:"from_country,omitempty"`
	FromZip        string         `json:"from_zip,omitempty"`
	FromState      string         `json:"from_state,omitempty"`
	FromCity       string         `json:"from_city,omitempty"`
	FromStreet     string         `json:"from_street,omitempty"`
	ToCountry      string         `json:"to_country,omitempty"`
	ToZip          string         `json:"to_zip,omitempty"`
	ToState        string         `json:"to_state,omitempty"`
	ToCity         string         `json:"to_city,omitempty"`
	ToStreet       string         `json:"to_street,omitempty"`
	Amount         float64        `json:"amount,omitempty"`
	Shipping       float64        `json:"shipping"`
	CustomerID     string         `json:"customer_id,omitempty"`
	ExemptionType  string         `json:"exemption_type,omitempty"`
	NexusAddresses []NexusAddress `json:"nexus_addresses,omitempty"`
	LineItems      []TaxLineItem  `json:"line_items,omitempty"`
}

TaxForOrderParams should be passed to `TaxForOrder` to calculate tax․

type TaxForOrderResponse

type TaxForOrderResponse struct {
	Tax Tax `json:"tax"`
}

TaxForOrderResponse is the structure returned from `TaxForOrder`․

Access the calculated tax with `TaxForOrderResponse.Tax`․

type TaxLineItem

type TaxLineItem struct {
	ID             string  `json:"id,omitempty"`
	Quantity       int     `json:"quantity,omitempty"`
	ProductTaxCode string  `json:"product_tax_code,omitempty"`
	UnitPrice      float64 `json:"unit_price,omitempty"`
	Discount       float64 `json:"discount,omitempty"`
}

TaxLineItem is the structure for a line item passed within `TaxForOrderParams.LineItems`․

type UpdateCustomerParams

type UpdateCustomerParams struct {
	CustomerID    string         `json:"customer_id,omitempty"`
	ExemptionType string         `json:"exemption_type,omitempty"`
	Name          string         `json:"name,omitempty"`
	ExemptRegions []ExemptRegion `json:"exempt_regions,omitempty"`
	Country       string         `json:"country,omitempty"`
	State         string         `json:"state,omitempty"`
	Zip           string         `json:"zip,omitempty"`
	City          string         `json:"city,omitempty"`
	Street        string         `json:"street,omitempty"`
}

UpdateCustomerParams should be passed to `UpdateCustomer` to update an existing customer․

type UpdateCustomerResponse

type UpdateCustomerResponse struct {
	CreateCustomerResponse
}

UpdateCustomerResponse is the structure returned from `UpdateCustomer`․

Access the updated customer with `UpdateCustomerResponse.Customer`.

type UpdateOrderParams

type UpdateOrderParams struct {
	TransactionID   string          `json:"transaction_id,omitempty"`
	TransactionDate string          `json:"transaction_date,omitempty"`
	FromCountry     string          `json:"from_country,omitempty"`
	FromZip         string          `json:"from_zip,omitempty"`
	FromState       string          `json:"from_state,omitempty"`
	FromCity        string          `json:"from_city,omitempty"`
	FromStreet      string          `json:"from_street,omitempty"`
	ToCountry       string          `json:"to_country,omitempty"`
	ToZip           string          `json:"to_zip,omitempty"`
	ToState         string          `json:"to_state,omitempty"`
	ToCity          string          `json:"to_city,omitempty"`
	ToStreet        string          `json:"to_street,omitempty"`
	Amount          float64         `json:"amount,omitempty"`
	Shipping        float64         `json:"shipping,omitempty"`
	SalesTax        float64         `json:"sales_tax,omitempty"`
	CustomerID      string          `json:"customer_id,omitempty"`
	ExemptionType   string          `json:"exemption_type,omitempty"`
	LineItems       []OrderLineItem `json:"line_items,omitempty"`
}

UpdateOrderParams should be passed to `UpdateOrder` to update an existing order․

type UpdateOrderResponse

type UpdateOrderResponse struct {
	Order Order `json:"order"`
}

UpdateOrderResponse is the structure returned from `UpdateOrder`․

Access the updated order with `UpdateOrderResponse.Order`․

type UpdateRefundParams

type UpdateRefundParams struct {
	TransactionID          string           `json:"transaction_id,omitempty"`
	TransactionReferenceID string           `json:"transaction_reference_id,omitempty"`
	TransactionDate        string           `json:"transaction_date,omitempty"`
	FromCountry            string           `json:"from_country,omitempty"`
	FromZip                string           `json:"from_zip,omitempty"`
	FromState              string           `json:"from_state,omitempty"`
	FromCity               string           `json:"from_city,omitempty"`
	FromStreet             string           `json:"from_street,omitempty"`
	ToCountry              string           `json:"to_country,omitempty"`
	ToZip                  string           `json:"to_zip,omitempty"`
	ToState                string           `json:"to_state,omitempty"`
	ToCity                 string           `json:"to_city,omitempty"`
	ToStreet               string           `json:"to_street,omitempty"`
	Amount                 float64          `json:"amount,omitempty"`
	Shipping               float64          `json:"shipping,omitempty"`
	SalesTax               float64          `json:"sales_tax,omitempty"`
	CustomerID             string           `json:"customer_id,omitempty"`
	ExemptionType          string           `json:"exemption_type,omitempty"`
	LineItems              []RefundLineItem `json:"line_items,omitempty"`
}

UpdateRefundParams should be passed to `UpdateRefund` to update an existing refund․

type UpdateRefundResponse

type UpdateRefundResponse struct {
	Refund Refund `json:"refund"`
}

UpdateRefundResponse is the structure returned from `UpdateRefund`․

Access the updated refund with `UpdateRefundResponse.Refund`․

type VIESResponse

type VIESResponse struct {
	CountryCode string `json:"country_code"`
	VATNumber   string `json:"vat_number"`
	RequestDate string `json:"request_date"`
	Valid       bool   `json:"valid"`
	Name        string `json:"name"`
	Address     string `json:"address"`
}

VIESResponse is the structure for a response from VIES (http://ec.europa.eu/taxation_customs/vies/) returned as `ValidateResponse.Validation.ViesResponse`․

type ValidateAddressParams

type ValidateAddressParams struct {
	Country string `json:"country,omitempty"`
	State   string `json:"state,omitempty"`
	Zip     string `json:"zip,omitempty"`
	City    string `json:"city,omitempty"`
	Street  string `json:"street,omitempty"`
}

ValidateAddressParams should be passed to `ValidateAddress` to validate an address․

type ValidateAddressResponse

type ValidateAddressResponse struct {
	Addresses []Address `json:"addresses"`
}

ValidateAddressResponse is the structure returned from `ValidateAddress․`

Access the returned list of address matches with `ValidateAddressResponse.Addresses`․

type ValidateParams

type ValidateParams struct {
	VAT string `url:"vat,omitempty"`
}

ValidateParams should be passed to `Validate` to validate a VAT identification number with VIES (http://ec.europa.eu/taxation_customs/vies/)․

type ValidateResponse

type ValidateResponse struct {
	Validation Validation `json:"validation"`
}

ValidateResponse is the structure returned from `Validate`․

Access the validation with `ValidateResponse.Validation`․

type Validation

type Validation struct {
	Valid         bool         `json:"valid"`
	Exists        bool         `json:"exists"`
	VIESAvailable bool         `json:"vies_available"`
	VIESResponse  VIESResponse `json:"vies_response"`
}

Validation is the structure for a VAT identification number validation returned within `ValidateResponse`․

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL