-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #555 from stripe/remi-add-tax-ids
Add support for TaxId resource and APIs
- Loading branch information
Showing
8 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from stripe import util | ||
from stripe.api_resources.customer import Customer | ||
from stripe.api_resources.abstract import APIResource | ||
from stripe.six.moves.urllib.parse import quote_plus | ||
|
||
|
||
class TaxId(APIResource): | ||
OBJECT_NAME = "tax_id" | ||
|
||
def instance_url(self): | ||
token = util.utf8(self.id) | ||
customer = util.utf8(self.customer) | ||
base = Customer.class_url() | ||
cust_extn = quote_plus(customer) | ||
extn = quote_plus(token) | ||
return "%s/%s/tax_ids/%s" % (base, cust_extn, extn) | ||
|
||
@classmethod | ||
def retrieve(cls, id, api_key=None, **params): | ||
raise NotImplementedError( | ||
"Can't retrieve a tax id without a customer ID. Use customer.retrieve_tax_id('tax_id')" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import pytest | ||
|
||
import stripe | ||
|
||
|
||
TEST_RESOURCE_ID = "txi_123" | ||
|
||
|
||
class TestTaxId(object): | ||
def construct_resource(self): | ||
tax_id_dict = { | ||
"id": TEST_RESOURCE_ID, | ||
"object": "tax_id", | ||
"customer": "cus_123", | ||
} | ||
return stripe.TaxId.construct_from(tax_id_dict, stripe.api_key) | ||
|
||
def test_has_instance_url(self, request_mock): | ||
resource = self.construct_resource() | ||
assert ( | ||
resource.instance_url() | ||
== "/v1/customers/cus_123/tax_ids/%s" % TEST_RESOURCE_ID | ||
) | ||
|
||
def test_is_not_retrievable(self, request_mock): | ||
with pytest.raises(NotImplementedError): | ||
stripe.TaxId.retrieve(TEST_RESOURCE_ID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters