tax_cloud 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +30 -0
  3. data/.rubocop.yml +1 -0
  4. data/CHANGELOG.md +85 -0
  5. data/Gemfile +0 -1
  6. data/LICENSE.md +21 -0
  7. data/README.md +200 -0
  8. data/Rakefile +0 -10
  9. data/lib/tax_cloud/errors/tax_cloud_error.rb +1 -1
  10. data/lib/tax_cloud/responses/authorized.rb +1 -1
  11. data/lib/tax_cloud/responses/authorized_with_capture.rb +1 -1
  12. data/lib/tax_cloud/responses/captured.rb +1 -1
  13. data/lib/tax_cloud/responses/cart_item.rb +1 -1
  14. data/lib/tax_cloud/responses/lookup.rb +1 -1
  15. data/lib/tax_cloud/responses/ping.rb +1 -1
  16. data/lib/tax_cloud/responses/returned.rb +1 -1
  17. data/lib/tax_cloud/responses/tax_code_groups.rb +1 -1
  18. data/lib/tax_cloud/responses/tax_codes.rb +1 -1
  19. data/lib/tax_cloud/responses/tax_codes_by_group.rb +1 -1
  20. data/lib/tax_cloud/responses/verify_address.rb +1 -1
  21. data/lib/tax_cloud/version.rb +1 -1
  22. data/lib/tax_cloud.rb +1 -1
  23. data/tax_cloud.gemspec +1 -0
  24. data/test/cassettes/authorized.yml +6 -6
  25. data/test/cassettes/authorized_with_capture.yml +6 -6
  26. data/test/cassettes/authorized_with_localized_time.yml +6 -6
  27. data/test/cassettes/captured.yml +7 -7
  28. data/test/cassettes/get_tic_groups.yml +5 -5
  29. data/test/cassettes/get_tics.yml +5 -5
  30. data/test/cassettes/get_tics_by_group.yml +5 -5
  31. data/test/cassettes/invalid_soap_call.yml +5 -5
  32. data/test/cassettes/lookup.yml +5 -5
  33. data/test/cassettes/lookup_ny.yml +5 -5
  34. data/test/cassettes/ping.yml +5 -5
  35. data/test/cassettes/ping_with_invalid_credentials.yml +5 -5
  36. data/test/cassettes/ping_with_invalid_response.yml +5 -5
  37. data/test/cassettes/returned.yml +7 -7
  38. data/test/cassettes/verify_bad_address.yml +5 -5
  39. data/test/cassettes/verify_good_address.yml +5 -5
  40. data/test/test_address.rb +4 -4
  41. metadata +21 -7
  42. data/.travis.yml +0 -6
  43. data/CHANGELOG.rdoc +0 -53
  44. data/LICENSE.rdoc +0 -22
  45. data/README.rdoc +0 -144
data/README.rdoc DELETED
@@ -1,144 +0,0 @@
1
- = TaxCloud
2
-
3
- {<img src="https://travis-ci.org/txcrb/tax_cloud.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/txcrb/tax_cloud]
4
-
5
- TaxCloud[http://www.taxcloud.com] is a free service to calculate sales tax and generate tax reports. The <tt>tax_cloud</tt> gem allows you to easily integrate with TaxCloud's API.
6
-
7
- === Getting Started
8
- Create a TaxCloud[http://www.taxcloud.com] merchant account at http://www.taxcloud.net. Add a website to your account under Locations[https://taxcloud.net/account/locations]. This will generate an API ID and API Key that you will need to use the service.
9
-
10
- TaxCloud[http://www.taxcloud.com] also offers an optional address verification API. To use it, you need a USPS (United States Postal Service) Address API Username. To obtain your USPS Username:
11
- 1. Go through the Web Tools API Portal registration process at https://registration.shippingapis.com/
12
- 2. Once you have registered for your account, you will receive an email with your USPS username and password.
13
- 3. Enter your USPS username in your TaxCloud initializer (see below).
14
-
15
- === Setup
16
- Add the gem to your Gemfile.
17
-
18
- gem 'tax_cloud'
19
-
20
- Configure your environment. For example, create an initializer in Rails in <tt>config/initializers/tax_cloud.rb</tt>.
21
-
22
- TaxCloud.configure do |config|
23
- config.api_login_id = 'your_tax_cloud_api_login_id'
24
- config.api_key = 'your_tax_cloud_api_key'
25
- config.usps_username = 'your_usps_username' # optional
26
- config.open_timeout = 1 # optional
27
- config.read_timeout = 1 # optional
28
- end
29
-
30
- The <tt>open_timeout</tt> and <tt>read_timeout</tt> options are used to specify waiting time for the TaxCloud web service response in seconds. Default values: <tt>open_timeout = 2</tt> and <tt>read_timeout = 2</tt>.
31
-
32
- === Using TaxCloud
33
- Define the destination and origin addresses using <tt>TaxCloud::Address</tt>.
34
-
35
- origin = TaxCloud::Address.new(
36
- :address1 => '162 East Avenue',
37
- :address2 => 'Third Floor',
38
- :city => 'Norwalk',
39
- :state => 'CT',
40
- :zip5 => '06851')
41
- destination = TaxCloud::Address.new(
42
- :address1 => '3121 West Government Way',
43
- :address2 => 'Suite 2B',
44
- :city => 'Seattle',
45
- :state => 'WA',
46
- :zip5 => '98199')
47
-
48
- Create your Transaction and set up your cart items
49
-
50
- transaction = TaxCloud::Transaction.new(
51
- :customer_id => '1',
52
- :cart_id => '1',
53
- :origin => origin,
54
- :destination => destination)
55
- transaction.cart_items << TaxCloud::CartItem.new(
56
- :index => 0,
57
- :item_id => 'SKU-100',
58
- :tic => TaxCloud::TaxCodes::GENERAL,
59
- :price => 10.00,
60
- :quantity => 1)
61
- lookup = transaction.lookup # this will return a TaxCloud::Responses::Lookup instance
62
- lookup.tax_amount # total tax amount
63
- lookup.cart_items.each do |cart_item|
64
- cart_item.tax_amount # tax for a single item
65
- end
66
-
67
- After you've authorized and captured the transaction via your merchant account, you should do the same with TaxCloud for maintaining accurate tax information.
68
-
69
- transaction.order_id = 100
70
- transaction.authorized_with_capture # returns "OK" or raises an error
71
-
72
- Later, you may need to mark some cart items as returned. TaxCloud will ignore any cart items that you don't include.
73
-
74
- transaction.order_id = 100
75
- transaction.cart_items << TaxCloud::CartItem.new(
76
- :index => 0,
77
- :item_id => 'SKU-100',
78
- :tic => TaxCloud::TaxCodes::GENERAL,
79
- :price => 10.00,
80
- :quantity => 1)
81
- transaction.returned # returns "OK" or raises an error
82
-
83
- === Verifying Addresses
84
-
85
- TaxCloud[http://www.taxcloud.com] optionally integrates with the USPS Address API. An address can be verified, which can also yield a 9-digit zip code that helps determine a more accurate tax rate.
86
-
87
- address = TaxCloud::Address.new({
88
- :address1 => '888 6th Ave',
89
- :city => 'New York',
90
- :state => 'New York',
91
- :zip5 => '10001'
92
- })
93
-
94
- verified_address = address.verify
95
- verified_address.zip5 # 10001
96
- verified_address.zip4 # 3502
97
- verified_address.zip # 10001-3502
98
-
99
- === Tax Codes
100
- TaxCloud[http://www.taxcloud.com] maintains a list of all Taxability Information Codes or TICs, which can be found at https://taxcloud.net/tic.
101
-
102
- You can obtain all tax codes as well as lookup a tax code by ID.
103
-
104
- TaxCloud::TaxCodes.all # a hash of all codes
105
- tax_code = TaxCloud::TaxCodes[TaxCloud::TaxCodes::DIRECT_MAIL_RELATED]
106
- tax_code.ticid # 11000 or TaxCloud::TaxCodes::DIRECT_MAIL_RELATED
107
- tax_code.description # "Direct-mail related"
108
-
109
- Tax codes are organized in groups.
110
-
111
- TaxCloud::TaxCode::Groups.all # a hash of all groups
112
- tax_code_group = TaxCloud::TaxCode::Groups[TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS]
113
- tax_code_group.group_id # 3 or TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS
114
- tax_code_group.description # School Related Products
115
- tax_code_group.tax_codes # a hash of all codes in this group
116
-
117
- Tax code constants are defined in <tt>tax_code_constants.rb</tt> and tax code group constants in <tt>tax_code_group_constants.rb</tt>. These files can be generated by running the following rake tasks.
118
-
119
- TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... tax_cloud:tax_codes
120
- TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... tax_cloud:tax_code_groups
121
-
122
- === Tax States
123
- TaxCloud manages a list of states in which you can calculate sales tax. The default setup will only have SSUTA (Streamlined Sales and Use Tax Agreement) states enabled. All other states will return $0 for tax values. To enable other states, go to https://taxcloud.com/go/states-management/. You can find more information about SSUTA here[http://www.streamlinedsalestax.org/index.php?page=About-Us].
124
-
125
- === Running Tests
126
- * VCR and WebMock are used to replay requests and avoid hitting the API each time. To refresh the mocks, simply delete the <tt>test/cassettes</tt> directory.
127
- * Run tests.
128
- rake test
129
- * If you need to record new requests against TaxCloud, set your keys first.
130
- TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... rake test
131
- The mocks will filter out your configuration details.
132
-
133
- === Bugs, fixes, etc
134
- * Fork.
135
- * Write test(s).
136
- * Fix.
137
- * Commit.
138
- * Submit pull request.
139
-
140
- === License
141
-
142
- Copyright Drew Tempelmeyer and contributors, 2011-2020.
143
-
144
- This gem is licensed under the MIT license.