Skip to content

Commit 076b9e6

Browse files
committed
Merge pull request #73 from recurly/2.2.0
bump 2.2.0
2 parents 9836471 + d528731 commit 076b9e6

File tree

11 files changed

+272
-2
lines changed

11 files changed

+272
-2
lines changed

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Version 2.2.0 May 14, 2014
2+
3+
- Added subscription preview: `subscription.preview()`
4+
- Added tax details to adjustments: `adjustment.tax_details`
5+
- Removed `taxable` support on adjustments
6+
- Added `tax_exempt` to accounts, adjustments and plans
7+
- Added `tax_rate`, `tax_type` to invoices and subscriptions
8+
- Added `tax_in_cents` to subscriptions
9+
110
## Version 2.1.15 April 8, 2014
211

312
- Added token_id support to BillingInfo

recurly/__init__.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"""
1919

2020

21-
__version__ = '2.1.15'
21+
__version__ = '2.2.0'
2222

2323
BASE_URI = 'https://%s.recurly.com/v2/'
2424
"""The API endpoint to send requests to."""
@@ -79,6 +79,7 @@ class Account(Resource):
7979
'last_name',
8080
'company_name',
8181
'vat_number',
82+
'tax_exempt',
8283
'accept_language',
8384
'created_at',
8485
)
@@ -351,6 +352,19 @@ class Redemption(Resource):
351352
'created_at',
352353
)
353354

355+
class TaxDetail(Resource):
356+
357+
"""A charge's tax breakdown"""
358+
359+
nodename = 'taxdetail'
360+
inherits_currency = True
361+
362+
attributes = (
363+
'name',
364+
'type',
365+
'tax_rate',
366+
'tax_in_cents',
367+
)
354368

355369
class Adjustment(Resource):
356370

@@ -369,13 +383,15 @@ class Adjustment(Resource):
369383
'tax_in_cents',
370384
'total_in_cents',
371385
'currency',
372-
'taxable',
386+
'tax_exempt',
387+
'tax_details',
373388
'start_date',
374389
'end_date',
375390
'created_at',
376391
'type',
377392
)
378393
xml_attribute_attributes = ('type',)
394+
_classes_for_nodename = {'tax_detail': TaxDetail,}
379395

380396

381397
class Invoice(Resource):
@@ -396,6 +412,8 @@ class Invoice(Resource):
396412
'vat_number',
397413
'subtotal_in_cents',
398414
'tax_in_cents',
415+
'tax_type',
416+
'tax_rate',
399417
'total_in_cents',
400418
'currency',
401419
'created_at',
@@ -479,6 +497,9 @@ class Subscription(Resource):
479497
'trial_started_at',
480498
'trial_ends_at',
481499
'unit_amount_in_cents',
500+
'tax_in_cents',
501+
'tax_type',
502+
'tax_rate',
482503
'total_billing_cycles',
483504
'timeframe',
484505
'currency',
@@ -617,6 +638,7 @@ class Plan(Resource):
617638
'trial_interval_unit',
618639
'accounting_code',
619640
'created_at',
641+
'tax_exempt',
620642
'unit_amount_in_cents',
621643
'setup_fee_in_cents',
622644
)

recurly/resource.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ def value_for_element(cls, elem):
405405
log.debug("Converting %r element with type %r", elem.tag, attr_type)
406406
if attr_type == 'integer':
407407
return int(elem.text.strip())
408+
if attr_type == 'float':
409+
return float(elem.text.strip())
408410
if attr_type == 'boolean':
409411
return elem.text.strip() == 'true'
410412
if attr_type == 'datetime':

tests/fixtures/account/show-taxed.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
GET https://api.recurly.com/v2/accounts/testmock HTTP/1.1
2+
Accept: application/xml
3+
Authorization: Basic YXBpa2V5Og==
4+
User-Agent: recurly-python/{version}
5+
6+

7+
HTTP/1.1 200 OK
8+
Content-Type: application/xml; charset=utf-8
9+
10+
<?xml version="1.0" encoding="UTF-8"?>
11+
<account href="https://api.recurly.com/v2/accounts/testmock">
12+
<adjustments href="https://api.recurly.com/v2/accounts/testmock/adjustments"/>
13+
<billing_info href="https://api.recurly.com/v2/accounts/testmock/billing_info"/>
14+
<invoices href="https://api.recurly.com/v2/accounts/testmock/invoices"/>
15+
<subscriptions href="https://api.recurly.com/v2/accounts/testmock/subscriptions"/>
16+
<transactions href="https://api.recurly.com/v2/accounts/testmock/transactions"/>
17+
<account_code>testmock</account_code>
18+
<username nil="nil"></username>
19+
<email nil="nil"></email>
20+
<first_name nil="nil"></first_name>
21+
<last_name nil="nil"></last_name>
22+
<company_name nil="nil"></company_name>
23+
<accept_language nil="nil"></accept_language>
24+
<tax_exempt type="boolean">true</tax_exempt>
25+
</account>

tests/fixtures/adjustment/account-has-adjustments.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,23 @@ X-Records: 1
1313
<uuid>4ba1531325014b4f969cd13676f514d8</uuid>
1414
<description>test charge</description>
1515
<account_code>chargemock</account_code>
16+
<tax_in_cents type="integer">5000</tax_in_cents>
1617
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
1718
<currency>USD</currency>
19+
<tax_details type="array">
20+
<tax_detail>
21+
<name>california</name>
22+
<type>state</type>
23+
<tax_rate type="float">0.065</tax_rate>
24+
<tax_in_cents type="integer">3000</tax_in_cents>
25+
</tax_detail>
26+
<tax_detail>
27+
<name>san francisco</name>
28+
<type>county</type>
29+
<tax_rate type="float">0.02</tax_rate>
30+
<tax_in_cents type="integer">2000</tax_in_cents>
31+
</tax_detail>
32+
</tax_details>
1833
<start_date type="datetime">2009-11-03T23:27:46Z</start_date>
1934
<end_date nil="nil" type="datetime"></end_date>
2035
<created_at type="datetime">2009-11-03T23:27:46Z</created_at>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
GET https://api.recurly.com/v2/accounts/chargemock/adjustments HTTP/1.1
2+
Accept: application/xml
3+
Authorization: Basic YXBpa2V5Og==
4+
User-Agent: recurly-python/{version}
5+
6+

7+
HTTP/1.1 200 OK
8+
Content-Type: application/xml; charset=utf-8
9+
X-Records: 1
10+
11+
<adjustments type="array">
12+
<adjustment type="charge">
13+
<uuid>4ba1531325014b4f969cd13676f514d8</uuid>
14+
<description>test charge</description>
15+
<account_code>chargemock</account_code>
16+
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
17+
<currency>USD</currency>
18+
<tax_exempt type="boolean">false</tax_exempt>
19+
<start_date type="datetime">2009-11-03T23:27:46Z</start_date>
20+
<end_date nil="nil" type="datetime"></end_date>
21+
<created_at type="datetime">2009-11-03T23:27:46Z</created_at>
22+
</adjustment>
23+
</adjustments>

tests/fixtures/invoice/show-taxed.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
GET https://api.recurly.com/v2/accounts/invoicemock/invoices HTTP/1.1
2+
Accept: application/xml
3+
Authorization: Basic YXBpa2V5Og==
4+
User-Agent: recurly-python/{version}
5+
6+

7+
HTTP/1.1 200 OK
8+
X-Records: 1
9+
Content-Type: application/xml; charset=utf-8
10+
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<invoices type="array">
13+
<invoice href="https://api.recurly.com/v2/invoices/4ba1531325014b4f969cd13676f514d8">
14+
<uuid>4ba1531325014b4f969cd13676f514d8</uuid>
15+
<account_code>invoicemock</account_code>
16+
<amount_in_cents>
17+
<USD type="integer">1000</USD>
18+
</amount_in_cents>
19+
<start_date type="datetime">2009-11-03T23:27:46-08:00</start_date>
20+
<end_date type="datetime"></end_date>
21+
<description>test charge</description>
22+
<created_at type="datetime">2009-11-03T23:27:46-08:00</created_at>
23+
<tax_type>usst</tax_type>
24+
</invoice>
25+
</invoices>

tests/fixtures/plan/show-taxed.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
GET https://api.recurly.com/v2/plans/planmock HTTP/1.1
2+
Accept: application/xml
3+
Authorization: Basic YXBpa2V5Og==
4+
User-Agent: recurly-python/{version}
5+
6+

7+
HTTP/1.1 200 OK
8+
Content-Type: application/xml; charset=utf-8
9+
10+
<?xml version="1.0" encoding="UTF-8"?>
11+
<plan href="https://api.recurly.com/v2/plans/planmock">
12+
<add_ons href="https://api.recurly.com/v2/plans/planmock/add_ons"/>
13+
<plan_code>planmock</plan_code>
14+
<name>Mock Plan</name>
15+
<description nil="nil"></description>
16+
<success_url nil="nil"></success_url>
17+
<cancel_url nil="nil"></cancel_url>
18+
<display_donation_amounts type="boolean">false</display_donation_amounts>
19+
<display_quantity type="boolean">false</display_quantity>
20+
<display_phone_number type="boolean">false</display_phone_number>
21+
<bypass_hosted_confirmation type="boolean">false</bypass_hosted_confirmation>
22+
<unit_name>unit</unit_name>
23+
<payment_page_tos_link nil="nil"></payment_page_tos_link>
24+
<plan_interval_length type="integer">1</plan_interval_length>
25+
<plan_interval_unit>months</plan_interval_unit>
26+
<trial_interval_length type="integer">0</trial_interval_length>
27+
<trial_interval_unit>days</trial_interval_unit>
28+
<created_at type="datetime">2011-10-03T22:23:12Z</created_at>
29+
<tax_exempt type="boolean">true</tax_exempt>
30+
<unit_amount_in_cents>
31+
</unit_amount_in_cents>
32+
<setup_fee_in_cents>
33+
</setup_fee_in_cents>
34+
</plan>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
GET https://api.recurly.com/v2/accounts/subscribemock/subscriptions HTTP/1.1
2+
Accept: application/xml
3+
Authorization: Basic YXBpa2V5Og==
4+
User-Agent: recurly-python/{version}
5+
6+

7+
HTTP/1.1 200 OK
8+
X-Records: 1
9+
Content-Type: application/xml; charset=utf-8
10+
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<subscriptions type="array">
13+
<subscription
14+
href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab">
15+
<uuid>123456789012345678901234567890ab</uuid>
16+
<account href="https://api.recurly.com/v2/accounts/subscribemock"/>
17+
<plan href="https://api.recurly.com/v2/plans/basicplan">
18+
<plan_code>basicplan</plan_code>
19+
<name>Basic Plan</name>
20+
</plan>
21+
<state>active</state>
22+
<quantity type="integer">1</quantity>
23+
<currency>EUR</currency>
24+
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
25+
<activated_at type="datetime">2011-05-27T07:00:00Z</activated_at>
26+
<canceled_at nil="nil"></canceled_at>
27+
<expires_at nil="nil"></expires_at>
28+
<current_period_started_at type="datetime">2011-06-27T07:00:00Z</current_period_started_at>
29+
<current_period_ends_at type="datetime">2010-07-27T07:00:00Z</current_period_ends_at>
30+
<trial_started_at nil="nil"></trial_started_at>
31+
<trial_ends_at nil="nil"></trial_ends_at>
32+
<tax_in_cents type="integer">0</tax_in_cents>
33+
<tax_type>usst</tax_type>
34+
<subscription_add_ons type="array">
35+
</subscription_add_ons>
36+
</subscription>
37+
</subscriptions>

tests/fixtures/subscription/show.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
GET https://api.recurly.com/v2/accounts/subscribemock/subscriptions HTTP/1.1
2+
Accept: application/xml
3+
Authorization: Basic YXBpa2V5Og==
4+
User-Agent: recurly-python/{version}
5+
6+

7+
HTTP/1.1 200 OK
8+
X-Records: 1
9+
Content-Type: application/xml; charset=utf-8
10+
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<subscriptions type="array">
13+
<subscription
14+
href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab">
15+
<uuid>123456789012345678901234567890ab</uuid>
16+
<account href="https://api.recurly.com/v2/accounts/subscribemock"/>
17+
<plan href="https://api.recurly.com/v2/plans/basicplan">
18+
<plan_code>basicplan</plan_code>
19+
<name>Basic Plan</name>
20+
</plan>
21+
<state>active</state>
22+
<quantity type="integer">1</quantity>
23+
<currency>EUR</currency>
24+
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
25+
<activated_at type="datetime">2011-05-27T07:00:00Z</activated_at>
26+
<canceled_at nil="nil"></canceled_at>
27+
<expires_at nil="nil"></expires_at>
28+
<current_period_started_at type="datetime">2011-06-27T07:00:00Z</current_period_started_at>
29+
<current_period_ends_at type="datetime">2010-07-27T07:00:00Z</current_period_ends_at>
30+
<trial_started_at nil="nil"></trial_started_at>
31+
<trial_ends_at nil="nil"></trial_ends_at>
32+
<tax_in_cents type="integer">0</tax_in_cents>
33+
<tax_type>usst</tax_type>
34+
<subscription_add_ons type="array">
35+
</subscription_add_ons>
36+
</subscription>
37+
</subscriptions>

0 commit comments

Comments
 (0)