Metadata-Version: 2.4
Name: myropay
Version: 1.0.0
Summary: Official Python library for the MyroPay API
License: MIT
Project-URL: Homepage, https://dev.myropay.com
Project-URL: Repository, https://github.com/myropayme/myropay-python
Keywords: myropay,payments,checkout,africa,fintech
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# myropay-python

Official Python library for the [MyroPay](https://myropay.com) API. No third-party dependencies — uses the standard library's `urllib`.

## Install

```
pip install myropay
```

## Usage

```python
import myropay
myropay.api_key = 'sk_test_...'

charge = myropay.Charge.create(
    email='customer@email.com',
    amount=500000,       # whole currency units — ₦500,000, not kobo
    currency='NGN',       # optional, defaults to NGN
    reference='ORD-1029', # optional, your own order id
)

print(charge.checkout_url)  # redirect your customer here
```

Retrieve a charge later:

```python
charge = myropay.Charge.retrieve('cs_test_...')
if charge.status == 'completed':
    ...  # fulfil the order
```

## Important

- `api_key` (`sk_live_...` / `sk_test_...`) must **never** reach a browser — use this library from your own server/backend only. Get your keys from the MyroPay business dashboard under **API & Apps**.
- Amounts are in the currency's own whole units (e.g. `500000` NGN = ₦500,000), not subunits like kobo or cents.
- For a client-side "Pay with MyroPay" button/modal that never needs your secret key, use the [Checkout SDK](https://dev.myropay.com#sdk) (`myropay.js`) instead — this package is for server-side charge creation and verification.

## Errors

```python
from myropay.error import MyroPayError

try:
    myropay.Charge.create(amount=5000)  # missing email
except MyroPayError as e:
    print(e.message, e.http_status)
```

`InvalidRequestError` is raised for missing/invalid parameters before a request is sent; `APIError` (and `AuthenticationError` for a bad key) for errors returned by the API itself.

## License

MIT
