taxamo-ns 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/LICENSE +11 -0
- data/README.md +152 -0
- data/Rakefile +7 -0
- data/lib/monkey.rb +90 -0
- data/lib/swagger/configuration.rb +21 -0
- data/lib/swagger/request.rb +199 -0
- data/lib/swagger/response.rb +87 -0
- data/lib/swagger.rb +93 -0
- data/lib/taxamo/models/additionalcurrencies.rb +63 -0
- data/lib/taxamo/models/additionalcurrency.rb +88 -0
- data/lib/taxamo/models/bycountry.rb +78 -0
- data/lib/taxamo/models/bystatus.rb +70 -0
- data/lib/taxamo/models/bytaxationtype.rb +83 -0
- data/lib/taxamo/models/c.rb +78 -0
- data/lib/taxamo/models/calculatesimpletaxout.rb +75 -0
- data/lib/taxamo/models/calculatetaxin.rb +63 -0
- data/lib/taxamo/models/calculatetaxlocationout.rb +98 -0
- data/lib/taxamo/models/calculatetaxout.rb +75 -0
- data/lib/taxamo/models/canceltransactionout.rb +63 -0
- data/lib/taxamo/models/capturepaymentout.rb +63 -0
- data/lib/taxamo/models/confirmtransactionin.rb +63 -0
- data/lib/taxamo/models/confirmtransactionout.rb +75 -0
- data/lib/taxamo/models/countries.rb +113 -0
- data/lib/taxamo/models/country.rb +120 -0
- data/lib/taxamo/models/countryschema.rb +120 -0
- data/lib/taxamo/models/createpaymentin.rb +73 -0
- data/lib/taxamo/models/createpaymentout.rb +63 -0
- data/lib/taxamo/models/createrefundin.rb +83 -0
- data/lib/taxamo/models/createrefundout.rb +78 -0
- data/lib/taxamo/models/createsmstokenin.rb +68 -0
- data/lib/taxamo/models/createsmstokenout.rb +63 -0
- data/lib/taxamo/models/createtransactionin.rb +68 -0
- data/lib/taxamo/models/createtransactionout.rb +75 -0
- data/lib/taxamo/models/currencyschema.rb +83 -0
- data/lib/taxamo/models/customfields.rb +68 -0
- data/lib/taxamo/models/emailinvoicein.rb +63 -0
- data/lib/taxamo/models/emailinvoiceout.rb +63 -0
- data/lib/taxamo/models/emailrefundin.rb +63 -0
- data/lib/taxamo/models/emailrefundout.rb +63 -0
- data/lib/taxamo/models/evidence.rb +113 -0
- data/lib/taxamo/models/evidenceschema.rb +78 -0
- data/lib/taxamo/models/getcountriesdictout.rb +64 -0
- data/lib/taxamo/models/getcurrenciesdictout.rb +64 -0
- data/lib/taxamo/models/getdailysettlementstatsout.rb +64 -0
- data/lib/taxamo/models/getdetailedrefundsout.rb +64 -0
- data/lib/taxamo/models/getdomesticsummaryreportout.rb +123 -0
- data/lib/taxamo/models/geteuviesreportout.rb +79 -0
- data/lib/taxamo/models/getproducttypesdictout.rb +64 -0
- data/lib/taxamo/models/getrefundsout.rb +64 -0
- data/lib/taxamo/models/getsettlementout.rb +84 -0
- data/lib/taxamo/models/getsettlementstatsbycountryout.rb +64 -0
- data/lib/taxamo/models/getsettlementstatsbytaxationtypeout.rb +63 -0
- data/lib/taxamo/models/getsettlementsummaryout.rb +63 -0
- data/lib/taxamo/models/gettransactionout.rb +75 -0
- data/lib/taxamo/models/gettransactionsstatsbycountryout.rb +64 -0
- data/lib/taxamo/models/gettransactionsstatsout.rb +63 -0
- data/lib/taxamo/models/inputtransaction.rb +220 -0
- data/lib/taxamo/models/inputtransactionline.rb +144 -0
- data/lib/taxamo/models/inputtransactionupdate.rb +220 -0
- data/lib/taxamo/models/invoiceaddress.rb +98 -0
- data/lib/taxamo/models/listpaymentsout.rb +64 -0
- data/lib/taxamo/models/listrefundsout.rb +64 -0
- data/lib/taxamo/models/listtransactionsout.rb +64 -0
- data/lib/taxamo/models/locategivenipout.rb +73 -0
- data/lib/taxamo/models/locatemyipout.rb +73 -0
- data/lib/taxamo/models/n.rb +78 -0
- data/lib/taxamo/models/payments.rb +73 -0
- data/lib/taxamo/models/producttypeschema.rb +63 -0
- data/lib/taxamo/models/refunds.rb +108 -0
- data/lib/taxamo/models/report.rb +103 -0
- data/lib/taxamo/models/settlementdailystatsschema.rb +103 -0
- data/lib/taxamo/models/storagerequiredfields.rb +63 -0
- data/lib/taxamo/models/summary.rb +98 -0
- data/lib/taxamo/models/taxdataschema.rb +63 -0
- data/lib/taxamo/models/taxrequiredfields.rb +63 -0
- data/lib/taxamo/models/transaction.rb +330 -0
- data/lib/taxamo/models/transactionlines.rb +174 -0
- data/lib/taxamo/models/transactions.rb +330 -0
- data/lib/taxamo/models/unconfirmtransactionin.rb +63 -0
- data/lib/taxamo/models/unconfirmtransactionout.rb +75 -0
- data/lib/taxamo/models/updatetransactionin.rb +63 -0
- data/lib/taxamo/models/updatetransactionout.rb +75 -0
- data/lib/taxamo/models/ustaxexemptioncertificatedetailsschema.rb +139 -0
- data/lib/taxamo/models/ustaxexemptioncertificateschema.rb +68 -0
- data/lib/taxamo/models/ustaxexemptstate.rb +73 -0
- data/lib/taxamo/models/ustaxid.rb +73 -0
- data/lib/taxamo/models/validatetaxnumberout.rb +78 -0
- data/lib/taxamo/models/verifysmstokenout.rb +63 -0
- data/lib/taxamo/version.rb +17 -0
- data/lib/taxamo.rb +1215 -0
- data/taxamo.gemspec +28 -0
- data/test/taxamo/connectivity_test.rb +55 -0
- data/test/taxamo/tax_test.rb +152 -0
- data/test/taxamo/transactions_api_test.rb +326 -0
- metadata +241 -0
data/taxamo.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
|
3
|
+
require 'taxamo/version'
|
4
|
+
|
5
|
+
spec = Gem::Specification.new do |s|
|
6
|
+
s.name = 'taxamo-ns'
|
7
|
+
s.version = Taxamo::VERSION
|
8
|
+
s.summary = 'Ruby bindings for the Taxamo API (namespaced)'
|
9
|
+
s.description = 'Taxamo provides a real-time Software as a Service (SaaS) solution for compliance with the new 2015 EU VAT rules on the sale of e-services. http://www.taxamo.com'
|
10
|
+
s.authors = ['Tomek Lipski']
|
11
|
+
s.email = ['tom@taxamo.com']
|
12
|
+
s.homepage = 'https://www.taxamo.com/apidocs/index.html'
|
13
|
+
s.license = 'Apache'
|
14
|
+
|
15
|
+
s.add_dependency('addressable', '~> 2')
|
16
|
+
s.add_dependency('typhoeus', '> 0.6.0')
|
17
|
+
s.add_dependency('require_all', '~> 1.3.2')
|
18
|
+
|
19
|
+
s.add_development_dependency('mocha', '~> 0.13.2')
|
20
|
+
s.add_development_dependency('shoulda', '~> 3.4.0')
|
21
|
+
s.add_development_dependency('test-unit')
|
22
|
+
s.add_development_dependency('rake')
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.require_paths = ['lib']
|
28
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright 2014-2015 Taxamo, Ltd.
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
require 'shoulda'
|
15
|
+
require 'taxamo'
|
16
|
+
|
17
|
+
class ConnectivityTest < Test::Unit::TestCase
|
18
|
+
|
19
|
+
should 'test_validate' do
|
20
|
+
Swagger.configure do |config|
|
21
|
+
config.api_key = 'SamplePrivateTestKey1'
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_raise(ValidationError) {
|
25
|
+
Taxamo.calculate_tax ({'__transaction' => {
|
26
|
+
'currency_code' => 'USD',
|
27
|
+
'buyer_ip' => '127.0.0.1',
|
28
|
+
'billing_country_code' => 'IE',
|
29
|
+
'force_country_code' => 'FR',
|
30
|
+
'transaction_lines' => [{'amount' => 200,
|
31
|
+
'custom_id' => 'line1'},
|
32
|
+
{'amount' => 100,
|
33
|
+
'product_type' => 'e-book',
|
34
|
+
'custom_id' => 'line2'}]}}) }
|
35
|
+
end
|
36
|
+
|
37
|
+
should 'test_auth' do
|
38
|
+
Swagger.configure do |config|
|
39
|
+
config.api_key = 'SamplePrivateTestKey1!'
|
40
|
+
end
|
41
|
+
assert_raise(AuthenticationError) {
|
42
|
+
Taxamo.calculate_tax ({'__transaction' => {
|
43
|
+
'currency_code' => 'USD',
|
44
|
+
'buyer_ip' => '127.0.0.1',
|
45
|
+
'billing_country_code' => 'IE',
|
46
|
+
'force_country_code' => 'FR',
|
47
|
+
'transaction_lines' => [{'amount' => 200,
|
48
|
+
'custom_id' => 'line1'},
|
49
|
+
{'amount' => 100,
|
50
|
+
'product_type' => 'e-book',
|
51
|
+
'custom_id' => 'line2'}]}})}
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# Copyright 2014-2015 Taxamo, Ltd.
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
require 'shoulda'
|
15
|
+
require 'taxamo'
|
16
|
+
|
17
|
+
|
18
|
+
class TaxTest < Test::Unit::TestCase
|
19
|
+
|
20
|
+
should 'basic tax calculation works' do
|
21
|
+
|
22
|
+
Swagger.configure do |config|
|
23
|
+
config.api_key = 'SamplePrivateTestKey1'
|
24
|
+
end
|
25
|
+
resp = Taxamo.calculate_tax(
|
26
|
+
{'transaction' => {
|
27
|
+
'currency_code' => 'USD',
|
28
|
+
'buyer_ip' => '127.0.0.1',
|
29
|
+
'billing_country_code' => 'IE',
|
30
|
+
'force_country_code' => 'FR',
|
31
|
+
'transaction_lines' => [{'amount' => 200,
|
32
|
+
'custom_id' => 'line1'},
|
33
|
+
{'amount' => 100,
|
34
|
+
'product_type' => 'e-book',
|
35
|
+
'custom_id' => 'line2'}]}})
|
36
|
+
|
37
|
+
assert_equal resp.transaction.countries.detected.code, 'IE'
|
38
|
+
assert_equal resp.transaction.amount, 300
|
39
|
+
assert_equal resp.transaction.tax_amount, 45.5
|
40
|
+
assert_equal resp.transaction.total_amount, 345.5
|
41
|
+
|
42
|
+
assert_equal resp.transaction.transaction_lines[0].custom_id, 'line1'
|
43
|
+
assert_equal resp.transaction.transaction_lines[0].tax_rate, 20
|
44
|
+
assert_equal resp.transaction.transaction_lines[0].tax_amount, 40
|
45
|
+
assert_equal resp.transaction.transaction_lines[1].custom_id, 'line2'
|
46
|
+
assert_equal resp.transaction.transaction_lines[1].tax_rate, 5.5
|
47
|
+
assert_equal resp.transaction.transaction_lines[1].tax_amount, 5.5
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
should 'data model works' do
|
52
|
+
|
53
|
+
Swagger.configure do |config|
|
54
|
+
config.api_key = 'SamplePrivateTestKey1'
|
55
|
+
end
|
56
|
+
|
57
|
+
taxIn = Taxamo::CalculateTaxIn.new
|
58
|
+
taxIn.transaction = Taxamo::InputTransaction.new
|
59
|
+
taxIn.transaction.currency_code = 'USD'
|
60
|
+
taxIn.transaction.buyer_ip = '127.0.0.1'
|
61
|
+
taxIn.transaction.billing_country_code = 'IE'
|
62
|
+
taxIn.transaction.force_country_code = 'FR'
|
63
|
+
taxIn.transaction.transaction_lines = [Taxamo::InputTransactionLine.new, Taxamo::InputTransactionLine.new]
|
64
|
+
taxIn.transaction.transaction_lines[0].amount = 200
|
65
|
+
taxIn.transaction.transaction_lines[0].custom_id = 'line1'
|
66
|
+
taxIn.transaction.transaction_lines[1].amount = 100
|
67
|
+
taxIn.transaction.transaction_lines[1].custom_id = 'line2'
|
68
|
+
taxIn.transaction.transaction_lines[1].product_type = 'e-book'
|
69
|
+
|
70
|
+
resp = Taxamo.calculate_tax(taxIn)
|
71
|
+
|
72
|
+
assert_equal resp.transaction.countries.detected.code, 'IE'
|
73
|
+
assert_equal resp.transaction.amount, 300
|
74
|
+
assert_equal resp.transaction.tax_amount, 45.5
|
75
|
+
assert_equal resp.transaction.total_amount, 345.5
|
76
|
+
|
77
|
+
assert_equal resp.transaction.transaction_lines[0].custom_id, 'line1'
|
78
|
+
assert_equal resp.transaction.transaction_lines[0].tax_rate, 20
|
79
|
+
assert_equal resp.transaction.transaction_lines[0].tax_amount, 40
|
80
|
+
assert_equal resp.transaction.transaction_lines[1].custom_id, 'line2'
|
81
|
+
assert_equal resp.transaction.transaction_lines[1].tax_rate, 5.5
|
82
|
+
assert_equal resp.transaction.transaction_lines[1].tax_amount, 5.5
|
83
|
+
end
|
84
|
+
|
85
|
+
should 'test simple calculate' do
|
86
|
+
|
87
|
+
Swagger.configure do |config|
|
88
|
+
config.api_key = 'SamplePrivateTestKey1'
|
89
|
+
end
|
90
|
+
#,,,,,
|
91
|
+
resp = Taxamo.calculate_simple_tax('e-book', #product_type
|
92
|
+
nil, #invoice_address_city
|
93
|
+
nil, #buyer_credit_card_prefix
|
94
|
+
'USD', #currency_code
|
95
|
+
nil, #invoice_address_region
|
96
|
+
nil, #unit_price
|
97
|
+
nil, #quantity
|
98
|
+
nil, #buyer_tax_number
|
99
|
+
'FR', #force_country_code
|
100
|
+
nil, #order_date
|
101
|
+
100, #amount
|
102
|
+
'IE', #billing_country_code
|
103
|
+
nil, #invoice_address_postal_code
|
104
|
+
nil, #total_amount
|
105
|
+
nil #tax_deducted
|
106
|
+
)
|
107
|
+
|
108
|
+
assert_equal resp.transaction.tax_country_code, 'FR'
|
109
|
+
assert_equal resp.transaction.amount, 100
|
110
|
+
assert_equal resp.transaction.tax_amount, 5.5
|
111
|
+
assert_equal resp.transaction.total_amount, 105.5
|
112
|
+
|
113
|
+
assert_equal resp.transaction.transaction_lines[0].tax_rate, 5.5
|
114
|
+
assert_equal resp.transaction.transaction_lines[0].tax_rate, 5.5
|
115
|
+
assert_equal resp.transaction.transaction_lines[0].total_amount, 105.5
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
should 'test validate tax number' do
|
120
|
+
|
121
|
+
Swagger.configure do |config|
|
122
|
+
config.api_key = 'SamplePrivateTestKey1'
|
123
|
+
end
|
124
|
+
resp = Taxamo.validate_tax_number(nil, 'IE6388047V')
|
125
|
+
assert_equal resp.tax_deducted, true
|
126
|
+
assert_equal resp.billing_country_code, 'IE'
|
127
|
+
|
128
|
+
resp = Taxamo.validate_tax_number('IE', '6388047V')
|
129
|
+
assert_equal resp.tax_deducted, true
|
130
|
+
assert_equal resp.billing_country_code, 'IE'
|
131
|
+
|
132
|
+
resp = Taxamo.validate_tax_number('IE', '6388047V12121')
|
133
|
+
|
134
|
+
assert_equal resp.tax_deducted, nil
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
should 'test_location_calculate' do
|
139
|
+
|
140
|
+
Swagger.configure do |config|
|
141
|
+
config.api_key = 'SamplePrivateTestKey1'
|
142
|
+
end
|
143
|
+
|
144
|
+
resp = Taxamo.calculate_tax_location('BE', '424242')
|
145
|
+
assert_equal resp.tax_country_code, 'BE'
|
146
|
+
assert_equal resp.tax_supported, true
|
147
|
+
assert_equal resp.countries.detected.code, 'BE'
|
148
|
+
assert_equal resp.countries.by_billing.code, 'BE'
|
149
|
+
assert_equal resp.countries.by_cc.code, 'BE'
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,326 @@
|
|
1
|
+
# Copyright 2014-2015 Taxamo, Ltd.
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
require 'shoulda'
|
15
|
+
require 'taxamo'
|
16
|
+
|
17
|
+
class TransactionsApiTest < Test::Unit::TestCase
|
18
|
+
|
19
|
+
should 'test_ops' do
|
20
|
+
Swagger.configure do |config|
|
21
|
+
config.api_key = 'SamplePrivateTestKey1'
|
22
|
+
end
|
23
|
+
|
24
|
+
resp = Taxamo.create_transaction(
|
25
|
+
{
|
26
|
+
'transaction' => {
|
27
|
+
'currency_code' => 'USD',
|
28
|
+
'buyer_ip' => '127.0.0.1',
|
29
|
+
'billing_country_code' => 'IE',
|
30
|
+
'force_country_code' => 'FR',
|
31
|
+
'order_date' => '2014-06-01',
|
32
|
+
'buyer_email' => 'test-ruby@taxamo.com',
|
33
|
+
'transaction_lines' => [{'amount' => 200,
|
34
|
+
'custom_id' => 'line1'},
|
35
|
+
{'amount' => 100,
|
36
|
+
'product_type' => 'e-book',
|
37
|
+
'custom_id' => 'line2'}]
|
38
|
+
}})
|
39
|
+
assert_false resp.transaction.key.nil?
|
40
|
+
assert_equal resp.transaction.countries.detected.code, 'IE'
|
41
|
+
assert_equal resp.transaction.amount, 300
|
42
|
+
assert_equal resp.transaction.tax_amount, 45.5
|
43
|
+
assert_equal resp.transaction.total_amount, 345.5
|
44
|
+
assert_equal resp.transaction.status, 'N'
|
45
|
+
|
46
|
+
resp = Taxamo.get_transaction(resp.transaction.key)
|
47
|
+
|
48
|
+
assert_false resp.transaction.key.nil?
|
49
|
+
assert_equal resp.transaction.amount, 300
|
50
|
+
assert_equal resp.transaction.tax_amount, 45.5
|
51
|
+
assert_equal resp.transaction.total_amount, 345.5
|
52
|
+
assert_equal resp.transaction.status, 'N'
|
53
|
+
assert_equal resp.transaction.evidence.by_billing.resolved_country_code, 'IE'
|
54
|
+
assert_equal resp.transaction.evidence.by_ip.resolved_country_code, 'IE'
|
55
|
+
assert_equal resp.transaction.evidence.forced.resolved_country_code, 'FR'
|
56
|
+
assert_equal resp.transaction.buyer_email, 'test-ruby@taxamo.com'
|
57
|
+
|
58
|
+
|
59
|
+
resp = Taxamo.update_transaction(resp.transaction.key,
|
60
|
+
{'transaction' =>
|
61
|
+
{'buyer_name' => 'Ruby tester #2',
|
62
|
+
'currency_code' => 'CHF',
|
63
|
+
'invoice_address' => {'street_name' => 'Test street #4'},
|
64
|
+
'transaction_lines' => [{'amount' => 30,
|
65
|
+
'custom_id' => 'line1'},
|
66
|
+
{'amount' => 40,
|
67
|
+
'product_type' => 'e-book',
|
68
|
+
'custom_id' => 'line2'}]}})
|
69
|
+
|
70
|
+
assert_false resp.transaction.key.nil?
|
71
|
+
|
72
|
+
assert_equal resp.transaction.status, 'N'
|
73
|
+
assert_equal resp.transaction.amount, 70
|
74
|
+
assert_equal resp.transaction.tax_amount, 8.2
|
75
|
+
assert_equal resp.transaction.total_amount, 78.2
|
76
|
+
|
77
|
+
resp = Taxamo.get_transaction(resp.transaction.key)
|
78
|
+
|
79
|
+
assert_false resp.transaction.key.nil?
|
80
|
+
assert_equal resp.transaction.buyer_name, 'Ruby tester #2'
|
81
|
+
assert_equal resp.transaction.invoice_address.street_name, 'Test street #4'
|
82
|
+
|
83
|
+
assert_equal resp.transaction.status, 'N'
|
84
|
+
assert_equal resp.transaction.amount, 70
|
85
|
+
assert_equal resp.transaction.tax_amount, 8.2
|
86
|
+
assert_equal resp.transaction.total_amount, 78.2
|
87
|
+
assert_equal resp.transaction.evidence.by_billing.resolved_country_code, 'IE'
|
88
|
+
assert_equal resp.transaction.evidence.by_ip.resolved_country_code, 'IE'
|
89
|
+
assert_equal resp.transaction.evidence.forced.resolved_country_code, 'FR'
|
90
|
+
|
91
|
+
resp = Taxamo.confirm_transaction(resp.transaction.key,
|
92
|
+
{'transaction' =>
|
93
|
+
{'buyer_name' => 'Ruby tester',
|
94
|
+
'invoice_place' => 'Rubytown',
|
95
|
+
'currency_code' => 'EUR',
|
96
|
+
'transaction_lines' => [{'amount' => 300,
|
97
|
+
'custom_id' => 'line1'},
|
98
|
+
{'amount' => 400,
|
99
|
+
'product_type' => 'e-book',
|
100
|
+
'custom_id' => 'line2'}]}})
|
101
|
+
|
102
|
+
assert_false resp.transaction.key.nil?
|
103
|
+
assert_equal resp.transaction.status, 'C'
|
104
|
+
assert_equal resp.transaction.amount, 700
|
105
|
+
assert_equal resp.transaction.tax_amount, 82
|
106
|
+
assert_equal resp.transaction.total_amount, 782
|
107
|
+
|
108
|
+
resp = Taxamo.get_transaction(resp.transaction.key)
|
109
|
+
|
110
|
+
assert_false resp.transaction.key.nil?
|
111
|
+
assert_equal resp.transaction.status, 'C'
|
112
|
+
assert_equal resp.transaction.amount, 700
|
113
|
+
assert_equal resp.transaction.tax_amount, 82
|
114
|
+
assert_equal resp.transaction.total_amount, 782
|
115
|
+
assert_equal resp.transaction.evidence.by_billing.resolved_country_code, 'IE'
|
116
|
+
assert_equal resp.transaction.evidence.by_ip.resolved_country_code, 'IE'
|
117
|
+
assert_equal resp.transaction.evidence.forced.resolved_country_code, 'FR'
|
118
|
+
|
119
|
+
#filter_text,offset,key_or_custom_id,currency_code,order_date_to,sort_reverse,limit,invoice_number,statuses,order_date_from,total_amount_greater_than,format,total_amount_less_than,tax_country_code
|
120
|
+
resp = Taxamo.list_transactions(nil, #filter_text
|
121
|
+
0, #offset
|
122
|
+
nil, #key_or_custom_id
|
123
|
+
nil, #currency_code,
|
124
|
+
nil, #order_date_to,
|
125
|
+
'true', #sort_reverse
|
126
|
+
100, #limit
|
127
|
+
nil,#invoice_number
|
128
|
+
'C', #statuses
|
129
|
+
nil, #order_date_from
|
130
|
+
nil, #total_amount_greater_than
|
131
|
+
nil, #format,
|
132
|
+
nil, #total_amount_less_than
|
133
|
+
nil, #tax_country_code
|
134
|
+
nil, #original_transaction_key
|
135
|
+
nil, #has_note
|
136
|
+
nil #tax_country_codes
|
137
|
+
)
|
138
|
+
|
139
|
+
assert_true resp.transactions.length > 0
|
140
|
+
assert_true resp.transactions.length <= 100
|
141
|
+
|
142
|
+
resp.transactions.each do |transaction|
|
143
|
+
assert_equal transaction.status, 'C'
|
144
|
+
assert_equal transaction.currency_code, 'EUR'
|
145
|
+
end
|
146
|
+
resp = Taxamo.list_transactions(nil, #filter_text
|
147
|
+
0, #offset
|
148
|
+
nil, #key_or_custom_id
|
149
|
+
nil, #currency_code,
|
150
|
+
nil, #order_date_to,
|
151
|
+
'true', #sort_reverse
|
152
|
+
10, #limit
|
153
|
+
nil,#invoice_number
|
154
|
+
'N', #statuses
|
155
|
+
nil, #order_date_from
|
156
|
+
nil, #total_amount_greater_than
|
157
|
+
nil, #format,
|
158
|
+
nil, #total_amount_less_than
|
159
|
+
nil, #tax_country_code
|
160
|
+
nil, #original_transaction_key
|
161
|
+
nil, #has_note
|
162
|
+
nil #tax_country_codes
|
163
|
+
)
|
164
|
+
assert_true resp.transactions.length != 0
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
should "cancel test" do
|
169
|
+
Swagger.configure do |config|
|
170
|
+
config.api_key = 'SamplePrivateTestKey1'
|
171
|
+
end
|
172
|
+
resp = Taxamo.create_transaction(
|
173
|
+
{'transaction' => {
|
174
|
+
'currency_code' => 'USD',
|
175
|
+
'buyer_ip' => '127.0.0.1',
|
176
|
+
'billing_country_code' => 'IE',
|
177
|
+
'force_country_code' => 'FR',
|
178
|
+
'transaction_lines' => [{'amount' => 200,
|
179
|
+
'custom_id' => 'line1'},
|
180
|
+
{'amount' => 100,
|
181
|
+
'product_type' => 'e-book',
|
182
|
+
'custom_id' => 'line2'}]
|
183
|
+
}})
|
184
|
+
assert_false resp.transaction.key.nil?
|
185
|
+
assert_equal resp.transaction.status, 'N'
|
186
|
+
|
187
|
+
resp = Taxamo.cancel_transaction(resp.transaction.key)
|
188
|
+
|
189
|
+
assert_true resp.success
|
190
|
+
end
|
191
|
+
|
192
|
+
should 'evidence fields test' do
|
193
|
+
|
194
|
+
Swagger.configure do |config|
|
195
|
+
config.api_key = 'SamplePrivateTestKey1'
|
196
|
+
end
|
197
|
+
|
198
|
+
resp = Taxamo.create_transaction(
|
199
|
+
{'transaction' => {
|
200
|
+
'currency_code' => 'USD',
|
201
|
+
'evidence' => {
|
202
|
+
'other_commercially_relevant_info' => {'evidence_value' => 'GR'},
|
203
|
+
'self_declaration' => {'evidence_value' => 'GR'}
|
204
|
+
},
|
205
|
+
'billing_country_code' => 'GR',
|
206
|
+
'order_date' => '2014-06-01',
|
207
|
+
'buyer_email' => 'test-Ruby@taxamo.com',
|
208
|
+
'transaction_lines' => [{'amount' => 200,
|
209
|
+
'custom_id' => 'line1'},
|
210
|
+
{'amount' => 100,
|
211
|
+
'product_type' => 'e-book',
|
212
|
+
'custom_id' => 'line2'}]
|
213
|
+
}})
|
214
|
+
assert_false resp.transaction.key.nil?
|
215
|
+
assert_equal resp.transaction.countries.detected.code, 'GR'
|
216
|
+
assert_equal resp.transaction.countries.other_commercially_relevant_info.code, 'GR'
|
217
|
+
assert_equal resp.transaction.countries.self_declaration.code, 'GR'
|
218
|
+
assert_equal resp.transaction.status, 'N'
|
219
|
+
|
220
|
+
resp = Taxamo.get_transaction(resp.transaction.key)
|
221
|
+
|
222
|
+
assert_false resp.transaction.key.nil?
|
223
|
+
assert_equal resp.transaction.status, 'N'
|
224
|
+
assert_equal resp.transaction.evidence.by_billing.resolved_country_code, 'GR'
|
225
|
+
assert_equal resp.transaction.evidence.other_commercially_relevant_info.resolved_country_code, 'GR'
|
226
|
+
assert_equal resp.transaction.evidence.self_declaration.resolved_country_code, 'GR'
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
should "test custom fields" do
|
231
|
+
resp = Taxamo.create_transaction(
|
232
|
+
{'transaction' => {
|
233
|
+
'currency_code' => 'USD',
|
234
|
+
'buyer_ip' => '127.0.0.1',
|
235
|
+
'billing_country_code' => 'IE',
|
236
|
+
'force_country_code' => 'FR',
|
237
|
+
'order_date' => '2014-06-01',
|
238
|
+
'custom_fields' => [{'key' => 'test1', 'value' => 'test2'},
|
239
|
+
{'key' => 'test1', 'value' => 'test3'}],
|
240
|
+
'transaction_lines' => [{'amount' => 200,
|
241
|
+
'custom_id' => 'line1',
|
242
|
+
'custom_fields' => [{'key' => 'test11', 'value' => 'test22'},
|
243
|
+
{'key' => 'test41', 'value' => 'test23'}]},
|
244
|
+
{'amount' => 100,
|
245
|
+
'product_type' => 'e-book',
|
246
|
+
'custom_id' => 'line2'}]
|
247
|
+
}})
|
248
|
+
|
249
|
+
assert_false resp.transaction.key.nil?
|
250
|
+
assert_equal resp.transaction.status, 'N'
|
251
|
+
assert_equal resp.transaction.custom_fields[0].key, 'test1'
|
252
|
+
assert_equal resp.transaction.custom_fields[1].value, 'test3'
|
253
|
+
|
254
|
+
resp = Taxamo.get_transaction(resp.transaction.key)
|
255
|
+
|
256
|
+
assert_false resp.transaction.key.nil?
|
257
|
+
assert_equal resp.transaction.status, 'N'
|
258
|
+
assert_equal resp.transaction.custom_fields[0].key, 'test1'
|
259
|
+
assert_equal resp.transaction.custom_fields[1].value, 'test3'
|
260
|
+
assert_equal resp.transaction.transaction_lines[0].custom_fields[1].value, 'test23'
|
261
|
+
|
262
|
+
resp = Taxamo.update_transaction(resp.transaction.key,
|
263
|
+
{'transaction' =>
|
264
|
+
{'buyer_name' => 'Ruby tester #2',
|
265
|
+
'currency_code' => 'CHF',
|
266
|
+
'invoice_address' => {'street_name' => 'Test street #4'},
|
267
|
+
'custom_fields' => [{'key' => 'test51', 'value' => 'test52'},
|
268
|
+
{'key' => 'test51', 'value' => 'test53'},
|
269
|
+
{'key' => 'test61', 'value' => 'test63'}],
|
270
|
+
'transaction_lines' => [{'amount' => 30,
|
271
|
+
'custom_id' => 'line1',
|
272
|
+
'custom_fields' => [{'key' => 'test11', 'value' => 'test22'},
|
273
|
+
{'key' => 'test41', 'value' => 'test43'}]},
|
274
|
+
{'amount' => 40,
|
275
|
+
'product_type' => 'e-book',
|
276
|
+
'custom_id' => 'line2',
|
277
|
+
'custom_fields' => [{'key' => 'test21', 'value' => 'test82'},
|
278
|
+
{'key' => 'test71', 'value' => 'test83'}]}]}})
|
279
|
+
|
280
|
+
assert_false resp.transaction.key.nil?
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
resp = Taxamo.get_transaction(resp.transaction.key)
|
286
|
+
|
287
|
+
assert_false resp.transaction.key.nil?
|
288
|
+
assert_equal resp.transaction.status, 'N'
|
289
|
+
assert_equal resp.transaction.custom_fields[0].key, 'test51'
|
290
|
+
assert_equal resp.transaction.custom_fields[1].value, 'test53'
|
291
|
+
assert_equal resp.transaction.custom_fields[2].value, 'test63'
|
292
|
+
assert_equal resp.transaction.transaction_lines[0].custom_fields[1].value, 'test43'
|
293
|
+
assert_equal resp.transaction.transaction_lines[1].custom_fields[1].value, 'test83'
|
294
|
+
|
295
|
+
assert_raise(ValidationError) { Taxamo.capture_payment(resp.transaction.key)}
|
296
|
+
|
297
|
+
resp = Taxamo.list_transactions( nil, #filter_text
|
298
|
+
0, #offset
|
299
|
+
nil, #key_or_custom_id
|
300
|
+
nil, #currency_code,
|
301
|
+
nil, #order_date_to,
|
302
|
+
'true', #sort_reverse
|
303
|
+
10, #limit
|
304
|
+
nil,#invoice_number
|
305
|
+
'N', #statuses
|
306
|
+
nil, #order_date_from
|
307
|
+
nil, #total_amount_greater_than
|
308
|
+
nil, #format,
|
309
|
+
nil, #total_amount_less_than
|
310
|
+
nil, #tax_country_code
|
311
|
+
nil, #original_transaction_key
|
312
|
+
nil, #has_note
|
313
|
+
nil #tax_country_codes
|
314
|
+
)
|
315
|
+
|
316
|
+
assert_false resp.transactions[0].key.nil?
|
317
|
+
assert_equal resp.transactions[0].status, 'N'
|
318
|
+
assert_equal resp.transactions[0].custom_fields[0].key, 'test51'
|
319
|
+
assert_equal resp.transactions[0].custom_fields[1].value, 'test53'
|
320
|
+
assert_equal resp.transactions[0].custom_fields[2].value, 'test63'
|
321
|
+
assert_equal resp.transactions[0].transaction_lines[0].custom_fields[1].value, 'test43'
|
322
|
+
assert_equal resp.transactions[0].transaction_lines[1].custom_fields[1].value, 'test83'
|
323
|
+
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|