Skip to content

Commit

Permalink
Merge pull request #84 from andela-sjames/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
andela-sjames authored Apr 18, 2022
2 parents fe5cca9 + b1e0c67 commit 061b799
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ target/
.pypirc

.vscode/

notes.txt
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ paystack.subscription.list()

## DOC Reference: <https://developers.paystack.co/v2.0/reference>

### API Reference: [API](https://paystack.com/docs/api/)

### Other methods can be found in the docs folder

### Static Use
Expand Down Expand Up @@ -76,4 +78,4 @@ Verification

```

Please reference the **docs** folder for usage,
Please reference the **[docs](https://github.com/andela-sjames/paystack-python/tree/master/docs)** folder for usage,
16 changes: 13 additions & 3 deletions docs/customers.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,26 @@ response = Customer.get(customer_id=24)

JSON data from paystack API.

##### `Customer.list()` - List paystack customers
##### `Customer.list(perPage=50, page=6)` - List paystack customers

```python
from paystackapi.customer import Customer
response = Customer.list()
response = Customer.list(perPage=50, page=6)
```

*Arguments*

No argument required.
- `perPage`: Specify how many records you want to retrieve per page.
If not specify we use a default value of 50. (Integer)

- `page`: Specify exactly what page you want to retrieve.
defaults to 1 if not present(Integer)

- `from`: A timestamp from which to start listing customers.
e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime)

- `to`: A timestamp at which to stop listing customers.
e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime)

*Returns*

Expand Down
21 changes: 21 additions & 0 deletions docs/verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ response = Verification.verify_bvn(account_number='1234567890')
JSON data from paystack API.


##### `Verification.verify_bvn_match(bvn)` - verify BVN match with account number, first name and last name

```python
from paystackapi.verification import Verification
response = Verification.verify_bvn_match(bvn='1234567890',account_number='34334343',bank_code='34343' )
```

*Arguments*

- `bvn`: customer's bvn number
- `account_number`: customer's account number
- `bank_code`: customer's bank code
- `first_name`: customer's first name (Optional)
- `last_name`: customer's last name (Optional)
- `middle_name`: customer's middle name (Optional)

*Returns*

JSON data from paystack API.


##### `Verification.verify_account(account_number)` - verify a customer's BVN

```python
Expand Down
17 changes: 14 additions & 3 deletions paystackapi/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,27 @@ def get(cls, customer_id):
return cls().requests.get(f"customer/{customer_id}")

@classmethod
def list(cls):
def list(cls, **kwargs):
"""
Static method defined to list paystack customers.
Args:
No argument required.
perPage: Specify how many records you want to retrieve per page.
If not specify we use a default value of 50. (Integer)
page: Specify exactly what page you want to retrieve.
defaults to 1 if not present(Integer)
from: A timestamp from which to start listing customers
e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime)
to: A timestamp at which to stop listing customers
e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime)
Returns:
Json data from paystack API.
"""
return cls().requests.get('customer')
return cls().requests.get('customer', qs=kwargs,)

@classmethod
def update(cls, customer_id, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion paystackapi/tests/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_list(self):
status=201,
)

response = Customer.list()
response = Customer.list(perPage=50, page=6)
self.assertEqual(response['status'], True)

@httpretty.activate
Expand Down
18 changes: 18 additions & 0 deletions paystackapi/tests/test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ def test_verify_bvn(self):
response = Verification.verify_bvn(bvn='01234567689')
self.assertTrue(response['status'])


@httpretty.activate
def test_verify_bvn_match(self):
"""Method defined to test bvn match verification."""
httpretty.register_uri(
httpretty.POST,
self.endpoint_url("/bank/resolve"),
content_type='text/json',
body='{"status": true, "contributors": true}',
status=201,
)

response = Verification.verify_bvn_match(
bvn='01234567689',
account_number='123456',
bank_code='093')
self.assertTrue(response['status'])

@httpretty.activate
def test_verify_account(self):
"""Method defined to test account number verification."""
Expand Down
32 changes: 32 additions & 0 deletions paystackapi/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,38 @@ def verify_bvn(cls, bvn):
Json data from paystack API.
"""
return cls().requests.get(f"bank/resolve_bvn/{bvn}")

@classmethod
def verify_bvn_match(cls, **kwargs):
"""
Verify bvn match with account number, first name and last name
Args:
bvn: customer's bvn
account_number: customer's account number
bank_code: customer's bank code
first_name: customer's first name (Optional)
last_name: customer's last name (Optional)
middle_name: customer's middle name (Optional)
Returns:
Json data from paystack API.
{
"status": true,
"message": "BVN lookup successful",
"data": {
"bvn": "xxxxxxxxxxx",
"is_blacklisted": false,
"account_number": true,
"first_name": true,
"middle_name": false,
"last_name": true
},
"meta": {
"calls_this_month": 1,
"free_calls_left": 9
}
}
"""
return cls().requests.post('bank/resolve', data=kwargs)

@classmethod
def verify_account(cls, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ six==1.10.0
sure==1.2.24
tqdm==4.25.0
twine==1.11.0
urllib3==1.24.2
urllib3==1.26.5
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='paystackapi',
version='2.0.0',
version='2.1.0',
description='A python library to consume Paystack API',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 061b799

Please sign in to comment.