diff --git a/examples/check.py b/examples/check.py index b6fe624..3b623ac 100644 --- a/examples/check.py +++ b/examples/check.py @@ -47,7 +47,23 @@ print "=======================================================" print "\n" -# Creating a Check using the previously created bank account +# Verifying a Bank Account with the microdeposit amounts + +example_bank_account = lob.BankAccount.verify( + id = example_bank_account.id, + amounts = [23, 77] +) + +print "Bank Account Verify Response" +print "\n" +print "=======================================================" +print "\n" +print example_bank_account +print "\n" +print "=======================================================" +print "\n" + +# Creating a Check using the previously created and verified bank account example_check = lob.Check.create( name = 'Example Check', diff --git a/lob/resource.py b/lob/resource.py index 3aeca3c..00d8497 100644 --- a/lob/resource.py +++ b/lob/resource.py @@ -111,6 +111,13 @@ def create(cls, **params): response = requestor.request('post', cls.endpoint, params) return lob_format(response) +class VerifiableAPIResource(APIResource): + @classmethod + def verify(cls, id, **params): + requestor = api_requestor.APIRequestor() + response = requestor.request('post', '%s/%s/verify' % (cls.endpoint, id), params) + return lob_format(response) + class Address(ListableAPIResource, DeleteableAPIResource, CreateableAPIResource): endpoint = '/addresses' @@ -127,7 +134,7 @@ def create(cls, **params): params['routes'] = routes return super(Area, cls).create(**params) -class BankAccount(ListableAPIResource, DeleteableAPIResource, CreateableAPIResource): +class BankAccount(ListableAPIResource, DeleteableAPIResource, CreateableAPIResource, VerifiableAPIResource): endpoint = '/bank_accounts' class Check(ListableAPIResource, CreateableAPIResource): diff --git a/tests/test_bankaccount.py b/tests/test_bankaccount.py index 90de583..fcb9abc 100644 --- a/tests/test_bankaccount.py +++ b/tests/test_bankaccount.py @@ -79,9 +79,32 @@ def test_retrieve_bankAccount(self): def test_retrieve_bankAccount_fail(self): self.assertRaises(lob.error.InvalidRequestError, lob.BankAccount.retrieve, id='test') - def test_delete_bankAccount(self): ba = lob.BankAccount.list().data[0].id delBa = lob.BankAccount.delete(id=ba) self.assertEqual(ba, delBa.id) + def test_verify_bankAccount(self): + ba = lob.BankAccount.create( + routing_number='122100024', + account_number='223456789', + bank_address= { + 'name': 'Lob1', + 'address_line1': '185 Berry Street', + 'address_line2': 'Suite 1510', + 'address_city': 'San Francisco', + 'address_zip': '94107', + 'address_state': 'CA' + }, + account_address= { + 'name': 'Lob2', + 'address_line1': '185 Berry Street', + 'address_line2': 'Suite 1510', + 'address_city': 'San Francisco', + 'address_zip': '94107', + 'address_state': 'CA' + }, + signatory='John Doe' + ) + verBa = lob.BankAccount.verify(id=ba.id, amounts=[25, 75]) + self.assertTrue(verBa.verified) diff --git a/tests/test_check.py b/tests/test_check.py index e1ab491..d399f85 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -7,6 +7,8 @@ def setUp(self): lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc' self.addr = lob.Address.list(count=1).data[0] self.ba = lob.BankAccount.list(count=1).data[0] + if self.ba.verified == False: + lob.BankAccount.verify(id=self.ba.id, amounts=[20,80]) def test_list_checks(self): checks = lob.Check.list()