Skip to content

Commit

Permalink
Merge pull request #214 from stripe/gregsabo-account-reject-method
Browse files Browse the repository at this point in the history
Add bindings for account.reject
  • Loading branch information
brandur committed Mar 15, 2016
2 parents 224b322 + 6c9baef commit 0ceea01
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Note that PyCurl doesn't currently play nicely with our tox configuration. Tox

You can specify a module, TestCase or single test to run by passing it as an argument to tox. For example, to run only the `test_save` test of the `UpdateableAPIResourceTests` case from the `test.resources` module on Python 2.7:

tox -e py27 -- --test-suite stripe.test.resources.UpdateableAPIResourceTests.test_save
tox -e py27 -- --test-suite stripe.test.resources.test_updateable.UpdateableAPIResourceTests.test_save

### Linting

Expand Down
12 changes: 12 additions & 0 deletions stripe/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,18 @@ def instance_url(self):
extn = urllib.quote_plus(id)
return "%s/%s" % (base, extn)

def reject(self, reason=None, idempotency_key=None):
url = self.instance_url() + '/reject'
headers = populate_headers(idempotency_key)
if reason:
params = {"reason": reason}
else:
params = {}
self.refresh_from(
self.request('post', url, params, headers)
)
return self


class Balance(SingletonAPIResource):
pass
Expand Down
46 changes: 46 additions & 0 deletions stripe/test/resources/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,52 @@ def test_account_delete_bank_account(self):
None
)

def test_reject_account(self):
self.mock_response({
'id': 'acct_reject',
'verification': {
'disabled_reason': 'rejected.fraud'
},
})

obj = stripe.Account.construct_from({
'id': 'acct_reject'
}, 'mykey')

self.assertTrue(obj is obj.reject(reason='fraud'))
self.assertEqual('rejected.fraud', obj.verification['disabled_reason'])
self.assertEqual('acct_reject', obj.id)

self.requestor_mock.request.assert_called_with(
'post',
'/v1/accounts/acct_reject/reject',
{'reason': 'fraud'},
None
)

def test_reject_account_without_reason(self):
self.mock_response({
'id': 'acct_reject',
'verification': {
'disabled_reason': 'rejected.fraud'
},
})

obj = stripe.Account.construct_from({
'id': 'acct_reject'
}, 'mykey')

self.assertTrue(obj is obj.reject())
self.assertEqual('rejected.fraud', obj.verification['disabled_reason'])
self.assertEqual('acct_reject', obj.id)

self.requestor_mock.request.assert_called_with(
'post',
'/v1/accounts/acct_reject/reject',
{},
None
)

def test_verify_additional_owner(self):
acct = stripe.Account.construct_from({
'id': 'acct_update',
Expand Down

0 comments on commit 0ceea01

Please sign in to comment.