-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for /v1/topups endpoints.
- Loading branch information
1 parent
689baae
commit 912f505
Showing
4 changed files
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from stripe.api_resources.abstract import CreateableAPIResource | ||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class Topup(CreateableAPIResource, ListableAPIResource, UpdateableAPIResource): | ||
OBJECT_NAME = 'topup' |
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,58 @@ | ||
import stripe | ||
from tests.helper import StripeTestCase | ||
|
||
|
||
TEST_RESOURCE_ID = 'tu_123' | ||
|
||
|
||
class TopupTest(StripeTestCase): | ||
def test_is_listable(self): | ||
resources = stripe.Topup.list() | ||
self.assert_requested( | ||
'get', | ||
'/v1/topups' | ||
) | ||
self.assertIsInstance(resources.data, list) | ||
self.assertIsInstance(resources.data[0], stripe.Topup) | ||
|
||
def test_is_retrievable(self): | ||
resource = stripe.Topup.retrieve(TEST_RESOURCE_ID) | ||
self.assert_requested( | ||
'get', | ||
'/v1/topups/%s' % TEST_RESOURCE_ID | ||
) | ||
self.assertIsInstance(resource, stripe.Topup) | ||
|
||
def test_is_creatable(self): | ||
resource = stripe.Topup.create( | ||
amount=100, | ||
currency='usd', | ||
source='src_123', | ||
description='description', | ||
statement_descriptor='statement descriptor' | ||
) | ||
self.assert_requested( | ||
'post', | ||
'/v1/topups' | ||
) | ||
self.assertIsInstance(resource, stripe.Topup) | ||
|
||
def test_is_saveable(self): | ||
resource = stripe.Topup.retrieve(TEST_RESOURCE_ID) | ||
resource.metadata['key'] = 'value' | ||
resource.save() | ||
self.assert_requested( | ||
'post', | ||
'/v1/topups/%s' % resource.id | ||
) | ||
|
||
def test_is_modifiable(self): | ||
resource = stripe.Topup.modify( | ||
TEST_RESOURCE_ID, | ||
metadata={'key': 'value'} | ||
) | ||
self.assert_requested( | ||
'post', | ||
'/v1/topups/%s' % TEST_RESOURCE_ID | ||
) | ||
self.assertIsInstance(resource, stripe.Topup) |