Ejemplo n.º 1
0
    def test_validate(self):
        api_client = taxamo.swagger.ApiClient(TEST_TOKEN, TEST_ADDRESS)
        api = taxamo.api.ApiApi(api_client)
        self.assertRaises(
            taxamo.error.ValidationError, lambda: api.calculateTax({
                '__transaction': {
                    'currency_code':
                    'USD',
                    'buyer_ip':
                    '127.0.0.1',
                    'billing_country_code':
                    'IE',
                    'force_country_code':
                    'FR',
                    'transaction_lines': [{
                        'amount': 200,
                        'custom_id': 'line1'
                    }, {
                        'amount': 100,
                        'product_type': 'e-book',
                        'custom_id': 'line2'
                    }]
                }
            }))
        api_client.client = taxamo.http_client.Urllib2Client()

        api = taxamo.api.ApiApi(api_client)
        self.assertRaises(
            taxamo.error.ValidationError, lambda: api.calculateTax({
                '__transaction': {
                    'currency_code':
                    'USD',
                    'buyer_ip':
                    '127.0.0.1',
                    'billing_country_code':
                    'IE',
                    'force_country_code':
                    'FR',
                    'transaction_lines': [{
                        'amount': 200,
                        'custom_id': 'line1'
                    }, {
                        'amount': 100,
                        'product_type': 'e-book',
                        'custom_id': 'line2'
                    }]
                }
            }))
Ejemplo n.º 2
0
    def test_urllib2(self):
        api_client = taxamo.swagger.ApiClient(TEST_TOKEN, TEST_ADDRESS)
        api_client.client = taxamo.http_client.Urllib2Client()
        api = taxamo.api.ApiApi(api_client)

        resp = api.calculateTax({
            'transaction': {
                'currency_code':
                'USD',
                'buyer_ip':
                '127.0.0.1',
                'billing_country_code':
                'IE',
                'force_country_code':
                'FR',
                'transaction_lines': [{
                    'amount': 200,
                    'custom_id': 'line1'
                }, {
                    'amount': 100,
                    'product_type': 'e-book',
                    'custom_id': 'line2'
                }]
            }
        })
        self.assertEqual(resp.transaction.countries.detected.code, "IE")
        self.assertEqual(resp.transaction.amount, 300)
Ejemplo n.º 3
0
    def test_validate(self):
        api_client = taxamo.swagger.ApiClient(TEST_TOKEN, TEST_ADDRESS)
        api = taxamo.api.ApiApi(api_client)
        self.assertRaises(
            taxamo.error.ValidationError,
            lambda: api.calculateTax(
                {
                    '__transaction': {
                        'currency_code': 'USD',
                        'buyer_ip': '127.0.0.1',
                        'billing_country_code': 'IE',
                        'force_country_code': 'FR',
                        'transaction_lines': [{'amount': 200,
                                               'custom_id': 'line1'},
                                              {'amount': 100,
                                               'product_type': 'e-book',
                                               'custom_id': 'line2'}
                        ]
                    }}))
        api_client.client = taxamo.http_client.Urllib2Client()

        api = taxamo.api.ApiApi(api_client)
        self.assertRaises(
            taxamo.error.ValidationError,
            lambda: api.calculateTax(
                {
                    '__transaction': {
                        'currency_code': 'USD',
                        'buyer_ip': '127.0.0.1',
                        'billing_country_code': 'IE',
                        'force_country_code': 'FR',
                        'transaction_lines': [{'amount': 200,
                                               'custom_id': 'line1'},
                                              {'amount': 100,
                                               'product_type': 'e-book',
                                               'custom_id': 'line2'}
                        ]
                    }}))
Ejemplo n.º 4
0
    def test_urllib2(self):
        api_client = taxamo.swagger.ApiClient(TEST_TOKEN, TEST_ADDRESS)
        api_client.client = taxamo.http_client.Urllib2Client()
        api = taxamo.api.ApiApi(api_client)

        resp = api.calculateTax(
            {
                'transaction': {
                    'currency_code': 'USD',
                    'buyer_ip': '127.0.0.1',
                    'billing_country_code': 'IE',
                    'force_country_code': 'FR',
                    'transaction_lines': [{'amount': 200,
                                           'custom_id': 'line1'},
                                          {'amount': 100,
                                           'product_type': 'e-book',
                                           'custom_id': 'line2'}
                    ]
                }})
        self.assertEqual(resp.transaction.countries.detected.code, "IE")
        self.assertEqual(resp.transaction.amount, 300)
Ejemplo n.º 5
0
import taxamo.api
import taxamo.swagger

print "Calculating tax"

apiClient = taxamo.swagger.ApiClient("SamplePrivateTestKey1",
                                     "https://api.taxamo.com")
api = taxamo.api.ApiApi(apiClient)

resp = api.calculateTax({
    'transaction': {
        'currency_code': 'USD',
        'buyer_ip': '127.0.0.1',
        'billing_country_code': 'IE',
        'force_country_code': 'IE',
        'transaction_lines': [{
            'amount': 200,
            'custom_id': 'line1'
        }]
    }
})

print "Detected country: %s" % (resp.transaction.countries.detected.code)
print "Original amount: %d, tax amount: %d, total: %d" % (
    resp.transaction.amount, resp.transaction.tax_amount,
    resp.transaction.total_amount)
Ejemplo n.º 6
0
import taxamo.api
import taxamo.swagger

print "Calculating tax"

apiClient = taxamo.swagger.ApiClient("SamplePrivateTestKey1", "https://api.taxamo.com")
api = taxamo.api.ApiApi(apiClient)

resp = api.calculateTax(
    {
        'transaction': {
            'currency_code': 'USD',
            'buyer_ip': '127.0.0.1',
            'billing_country_code': 'IE',
            'force_country_code': 'IE',
            'transaction_lines': [{'amount': 200,
                                   'custom_id': 'line1'}]
        }})

print "Detected country: %s" % (resp.transaction.countries.detected.code)
print "Original amount: %d, tax amount: %d, total: %d" % (resp.transaction.amount,
                                                          resp.transaction.tax_amount,
                                                          resp.transaction.total_amount)