-
Notifications
You must be signed in to change notification settings - Fork 433
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 #455 from stripe/remi-add-issuing
Add support for Issuing APIs/resources
- Loading branch information
Showing
16 changed files
with
399 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
# flake8: noqa | ||
|
||
from stripe.api_resources.issuing.authorization import Authorization | ||
from stripe.api_resources.issuing.card import Card | ||
from stripe.api_resources.issuing.card_details import CardDetails | ||
from stripe.api_resources.issuing.cardholder import Cardholder | ||
from stripe.api_resources.issuing.dispute import Dispute | ||
from stripe.api_resources.issuing.transaction import Transaction |
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,21 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from stripe import util | ||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class Authorization(ListableAPIResource, UpdateableAPIResource): | ||
OBJECT_NAME = 'issuing.authorization' | ||
|
||
def approve(self, idempotency_key=None, **params): | ||
url = self.instance_url() + '/approve' | ||
headers = util.populate_headers(idempotency_key) | ||
self.refresh_from(self.request('post', url, params, headers)) | ||
return self | ||
|
||
def decline(self, idempotency_key=None, **params): | ||
url = self.instance_url() + '/decline' | ||
headers = util.populate_headers(idempotency_key) | ||
self.refresh_from(self.request('post', url, params, headers)) | ||
return self |
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,14 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from stripe.api_resources.abstract import CreateableAPIResource | ||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class Card(CreateableAPIResource, ListableAPIResource, | ||
UpdateableAPIResource): | ||
OBJECT_NAME = 'issuing.card' | ||
|
||
def details(self, idempotency_key=None, **params): | ||
return self.request( | ||
'get', self.instance_url() + '/details', params) |
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 __future__ import absolute_import, division, print_function | ||
|
||
from stripe.stripe_object import StripeObject | ||
|
||
|
||
class CardDetails(StripeObject): | ||
OBJECT_NAME = 'issuing.card_details' |
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,10 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from stripe.api_resources.abstract import CreateableAPIResource | ||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class Cardholder(CreateableAPIResource, ListableAPIResource, | ||
UpdateableAPIResource): | ||
OBJECT_NAME = 'issuing.cardholder' |
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,10 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from stripe.api_resources.abstract import CreateableAPIResource | ||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class Dispute(CreateableAPIResource, ListableAPIResource, | ||
UpdateableAPIResource): | ||
OBJECT_NAME = 'issuing.dispute' |
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,8 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class Transaction(ListableAPIResource, UpdateableAPIResource): | ||
OBJECT_NAME = 'issuing.transaction' |
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,67 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import stripe | ||
|
||
|
||
TEST_RESOURCE_ID = 'iauth_123' | ||
|
||
|
||
class TestAuthorization(object): | ||
def test_is_listable(self, request_mock): | ||
resources = stripe.issuing.Authorization.list() | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/authorizations' | ||
) | ||
assert isinstance(resources.data, list) | ||
assert isinstance(resources.data[0], stripe.issuing.Authorization) | ||
|
||
def test_is_modifiable(self, request_mock): | ||
resource = stripe.issuing.Authorization.modify( | ||
TEST_RESOURCE_ID, | ||
metadata={'key': 'value'} | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/authorizations/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Authorization) | ||
|
||
def test_is_retrievable(self, request_mock): | ||
resource = stripe.issuing.Authorization.retrieve(TEST_RESOURCE_ID) | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/authorizations/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Authorization) | ||
|
||
def test_is_saveable(self, request_mock): | ||
resource = stripe.issuing.Authorization.retrieve(TEST_RESOURCE_ID) | ||
resource.metadata['key'] = 'value' | ||
authorization = resource.save() | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/authorizations/%s' % resource.id | ||
) | ||
assert isinstance(resource, stripe.issuing.Authorization) | ||
assert resource is authorization | ||
|
||
def test_is_approveable(self, request_mock): | ||
resource = stripe.issuing.Authorization.retrieve(TEST_RESOURCE_ID) | ||
authorization = resource.approve() | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/authorizations/%s/approve' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Authorization) | ||
assert resource is authorization | ||
|
||
def test_is_declineable(self, request_mock): | ||
resource = stripe.issuing.Authorization.retrieve(TEST_RESOURCE_ID) | ||
authorization = resource.decline() | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/authorizations/%s/decline' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Authorization) | ||
assert resource is authorization |
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,67 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import stripe | ||
|
||
|
||
TEST_RESOURCE_ID = 'ic_123' | ||
|
||
|
||
class TestCard(object): | ||
def test_is_creatable(self, request_mock): | ||
resource = stripe.issuing.Card.create( | ||
currency='usd', | ||
type='physical' | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/cards' | ||
) | ||
assert isinstance(resource, stripe.issuing.Card) | ||
|
||
def test_is_listable(self, request_mock): | ||
resources = stripe.issuing.Card.list() | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/cards' | ||
) | ||
assert isinstance(resources.data, list) | ||
assert isinstance(resources.data[0], stripe.issuing.Card) | ||
|
||
def test_is_modifiable(self, request_mock): | ||
resource = stripe.issuing.Card.modify( | ||
TEST_RESOURCE_ID, | ||
metadata={'key': 'value'} | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/cards/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Card) | ||
|
||
def test_is_retrievable(self, request_mock): | ||
resource = stripe.issuing.Card.retrieve(TEST_RESOURCE_ID) | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/cards/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Card) | ||
|
||
def test_is_saveable(self, request_mock): | ||
resource = stripe.issuing.Card.retrieve(TEST_RESOURCE_ID) | ||
resource.metadata['key'] = 'value' | ||
card = resource.save() | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/cards/%s' % resource.id | ||
) | ||
assert isinstance(resource, stripe.issuing.Card) | ||
assert resource is card | ||
|
||
def test_can_retrieve_details(self, request_mock): | ||
resource = stripe.issuing.Card.retrieve(TEST_RESOURCE_ID) | ||
card_details = resource.details() | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/cards/%s/details' % resource.id | ||
) | ||
assert isinstance(card_details, stripe.issuing.CardDetails) |
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,66 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import stripe | ||
|
||
|
||
TEST_RESOURCE_ID = 'ich_123' | ||
|
||
|
||
class TestCardholder(object): | ||
def test_is_creatable(self, request_mock): | ||
resource = stripe.issuing.Cardholder.create( | ||
billing={ | ||
'address': { | ||
'city': 'city', | ||
'country': 'US', | ||
'line1': 'line1', | ||
'postal_code': 'postal_code', | ||
}, | ||
}, | ||
name='Jenny Rosen', | ||
type='individual' | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/cardholders' | ||
) | ||
assert isinstance(resource, stripe.issuing.Cardholder) | ||
|
||
def test_is_listable(self, request_mock): | ||
resources = stripe.issuing.Cardholder.list() | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/cardholders' | ||
) | ||
assert isinstance(resources.data, list) | ||
assert isinstance(resources.data[0], stripe.issuing.Cardholder) | ||
|
||
def test_is_modifiable(self, request_mock): | ||
resource = stripe.issuing.Cardholder.modify( | ||
TEST_RESOURCE_ID, | ||
metadata={'key': 'value'} | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/cardholders/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Cardholder) | ||
|
||
def test_is_retrievable(self, request_mock): | ||
resource = stripe.issuing.Cardholder.retrieve(TEST_RESOURCE_ID) | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/cardholders/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Cardholder) | ||
|
||
def test_is_saveable(self, request_mock): | ||
resource = stripe.issuing.Cardholder.retrieve(TEST_RESOURCE_ID) | ||
resource.metadata['key'] = 'value' | ||
cardholder = resource.save() | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/cardholders/%s' % resource.id | ||
) | ||
assert isinstance(resource, stripe.issuing.Cardholder) | ||
assert resource is cardholder |
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 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import stripe | ||
|
||
|
||
TEST_RESOURCE_ID = 'idp_123' | ||
|
||
|
||
class TestDispute(object): | ||
def test_is_creatable(self, request_mock): | ||
resource = stripe.issuing.Dispute.create( | ||
reason='fraudulent', | ||
transaction='ipi_123' | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/disputes' | ||
) | ||
assert isinstance(resource, stripe.issuing.Dispute) | ||
|
||
def test_is_listable(self, request_mock): | ||
resources = stripe.issuing.Dispute.list() | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/disputes' | ||
) | ||
assert isinstance(resources.data, list) | ||
assert isinstance(resources.data[0], stripe.issuing.Dispute) | ||
|
||
def test_is_modifiable(self, request_mock): | ||
resource = stripe.issuing.Dispute.modify( | ||
TEST_RESOURCE_ID, | ||
metadata={'key': 'value'} | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/disputes/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Dispute) | ||
|
||
def test_is_retrievable(self, request_mock): | ||
resource = stripe.issuing.Dispute.retrieve(TEST_RESOURCE_ID) | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/issuing/disputes/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.issuing.Dispute) | ||
|
||
def test_is_saveable(self, request_mock): | ||
resource = stripe.issuing.Dispute.retrieve(TEST_RESOURCE_ID) | ||
resource.metadata['key'] = 'value' | ||
dispute = resource.save() | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/issuing/disputes/%s' % resource.id | ||
) | ||
assert isinstance(resource, stripe.issuing.Dispute) | ||
assert resource is dispute |
Oops, something went wrong.