Skip to content

Commit

Permalink
Merge pull request #2 from gray-adeyi/v2.0.0-dev
Browse files Browse the repository at this point in the history
V2.0.0 dev
  • Loading branch information
gray-adeyi authored May 18, 2023
2 parents 8ed502a + b9e54f0 commit acc9ce5
Show file tree
Hide file tree
Showing 354 changed files with 10,352 additions and 80,594 deletions.
2 changes: 1 addition & 1 deletion .idea/pypaystack2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 4 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,20 @@
[![Downloads](https://static.pepy.tech/badge/pypaystack2/month)](https://pepy.tech/project/pypaystack2)
[![Downloads](https://static.pepy.tech/badge/pypaystack2/week)](https://pepy.tech/project/pypaystack2)

A developer friendly [Paystack](https://paystack.com/) API wrapper.
A developer-friendly [Paystack](https://paystack.com/) API wrapper.

## Installation

1. Create your [Paystack account](https://paystack.com/) to get your paystack secret key that is required to use this
package from your account's settings.
2. Store your paystack secret key in your environment variable as `PAYSTACK_AUTHORIZATION_KEY` or pass it into the
pypaystack api wrapper on instantiation. (protect your secret key at all cost, never push it to a remote version
pypaystack api wrapper on instantiation. (protect your secret key at all costs, never push it to a remote version
control system. it is advisable to start trying out this package with your test private key).
3. Install `pypaystack2` package.

```bash
pip install -U pypaystack2
```

## What's Pypaystack2

So [Paystack](https://paystack.com/) provides restful API endpoints for developers from different platforms
to integrate its services into their projects. So for python developers, to use
these endpoints, you might opt for a package like `requests` or `httpx` to handle all the
API calls which involves a lot of boilerplate. Pypaystack2 abstracts this process
by handling all these complexities under the hood and exposing simple APIs for
your python project.[See Pypaystack2's Documentation](https://gray-adeyi.github.io/pypaystack2/). You're encouraged to
use this documentation alongside [Paystack's official documentation](https://paystack.com/docs/)

```python
from pypaystack2 import Paystack # assumes you have installed pypaystack2
from pypaystack2.utils import Country

paystack = Paystack() # assumes that your paystack auth key is in
# your environmental variables i.e. PAYSTACK_AUTHORIZATION_KEY=your_paystack_secret_key otherwise instantiate
# the Paystack API wrapper as it is done below.
# paystack = Paystack(auth_key=your_paystack_secret_key)
response = paystack.miscellaneous.get_banks(country=Country.NIGERIA, use_cursor=False) # Requires internet connection.
print(response)
```

With the code snippet above, you have successfully queried Paystack's Miscellaneous API
to get a list of banks supported by paystack. A `requests` equivalent of the above will
be like

```python
import requests # assumes you have requests installed.

headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <your_auth_key>"
}
paystack_url = 'https://api.paystack.co/bank?perPage=50&country=ng&use_cursor=false'
response = requests.get(paystack_url, headers=headers) # requires internet connection
print(response.json())
```

While both approaches achieve the same goal, `pypaystack2` uses `requests` under the hood and
manages the headers and URL routes to endpoints, so you can focus more on the actions. with the `paystack`
wrapper in the example above, you can call all endpoints provided by paystack via `paystack.[api_group_name].[method]`
so for example associated with the `miscellaneous` attributes are methods provided like `.get_banks`, `.get_providers`,
`.get_countries` and `.get_states`. You can use them like so `paystack.miscellaneous.get_banks()`,
`paystack.miscellaneous.get_providers`. Say you wanted to verify a transaction with Paystack's Transaction API you can achieve that like
so `paystack.transactions.verify(reference="transaction-reference")`

Pypaystack2 currently provides wrappers to the following Paystack APIs via

```python
from pypaystack2 import Paystack # assumes you have installed pypaystack2

paystack = Paystack() # assumes that your paystack auth key is in
# your environmental variables i.e. PAYSTACK_AUTHORIZATION_KEY=your_paystack_secret_key otherwise instantiate
# the Paystack API wrapper as it is done below.
# paystack = Paystack(auth_key=your_paystack_secret_key)
paystack.apple_pay # Apple Pay API e.g paystack.apple_pay.get_domains()
paystack.bulk_charges # e.g. paystack.bulk_charges.get_batch()
paystack.charge # e.g. paystack.charge.check_pending_charge()
```

For more, [See Documentation](https://gray-adeyi.github.io/pypaystack2/)
## Documentation
See [Documentation](https://gray-adeyi.github.io/pypaystack2/) for more on this package.
20 changes: 0 additions & 20 deletions docs.old/Makefile

This file was deleted.

35 changes: 0 additions & 35 deletions docs.old/make.bat

This file was deleted.

60 changes: 0 additions & 60 deletions docs.old/source/conf.py

This file was deleted.

91 changes: 0 additions & 91 deletions docs.old/source/index.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs.old/source/modules.rst

This file was deleted.

Loading

0 comments on commit acc9ce5

Please sign in to comment.