Metadata-Version: 2.4
Name: mangopay4-python-sdk
Version: 4.0.0
Summary: A client library written in python to work with mangopay v2 api
License-Expression: MIT
License-File: LICENSE
Keywords: mangopay,api,development,emoney,sdk
Author: Mangopay (www.mangopay.com)
Author-email: support@mangopay.com
Requires-Python: >=3.10,<3.15
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: dev
Provides-Extra: test
Requires-Dist: blinker (>=1.9.0,<2)
Requires-Dist: coverage (==7.14.0) ; extra == "dev"
Requires-Dist: coverage (==7.14.0) ; extra == "test"
Requires-Dist: exam (==0.10.6) ; extra == "dev"
Requires-Dist: exam (==0.10.6) ; extra == "test"
Requires-Dist: httplib2 (==0.31.2) ; extra == "dev"
Requires-Dist: httplib2 (==0.31.2) ; extra == "test"
Requires-Dist: ndg-httpsclient (==0.5.1) ; extra == "dev"
Requires-Dist: ndg-httpsclient (==0.5.1) ; extra == "test"
Requires-Dist: pyasn1 (==0.6.3) ; extra == "dev"
Requires-Dist: pyasn1 (==0.6.3) ; extra == "test"
Requires-Dist: pynose (==1.5.5) ; extra == "dev"
Requires-Dist: pynose (==1.5.5) ; extra == "test"
Requires-Dist: pyopenssl (==26.1.0) ; extra == "dev"
Requires-Dist: pyopenssl (==26.1.0) ; extra == "test"
Requires-Dist: pytz (>=2026.2)
Requires-Dist: requests (>=2.34.2,<3)
Requires-Dist: responses (==0.26.0) ; extra == "dev"
Requires-Dist: responses (==0.26.0) ; extra == "test"
Requires-Dist: simplejson (>=3.20.2,<4)
Requires-Dist: six (>=1.17.0,<2)
Description-Content-Type: text/markdown

Mangopay Python SDK
=================================================

MangopaySDK is a Python client library to work with
[Mangopay REST API](http://docs.mangopay.com/api-references/).


Installation
------------

mangopaysdk requires Python >=3.10,<3.15 and the following runtime dependencies:

* [requests](https://pypi.python.org/pypi/requests)
* [simplejson](https://pypi.python.org/pypi/simplejson)
* [blinker](https://pypi.python.org/pypi/blinker)
* [six](https://pypi.python.org/pypi/six)
* [pytz](https://pypi.python.org/pypi/pytz)

To install the package:

```
    pip install mangopay4-python-sdk
```

By installing this package with [pip](https://pypi.python.org/pypi/pip), all dependencies will be installed for you.

### Development install

The project is managed with [Poetry](https://python-poetry.org/). To set up a local development environment:

```
    poetry install --extras dev
```

This installs the runtime dependencies as well as the `dev` extras (test runner, coverage, mocking, TLS helpers) defined in `pyproject.toml`. The resolved versions are pinned in `poetry.lock`.

To run the test suite (same command used in CI):

```
    poetry run coverage run -m unittest discover
    poetry run coverage xml
```


Documentation
-------------

For documentation and examples of usage for the Mangopay API please refer to: [API references](https://docs.mangopay.com/api-references/)

See the `docs/` directory to find examples.

mTLS certificates
-----------------

### Set the base URL for mTLS

Using mTLS authentication requires your integration to call a base URL with a different hostname from the standard API:

* Sandbox: `https://api-mtls.sandbox.mangopay.com`
* Production: `https://api-mtls.mangopay.com`

If using mTLS, your integration should use the `api-mtls` URLs for all API calls, including OAuth token generation.

**Caution:** Ensure you set the mTLS base URL, as shown in the configuration examples below. If you don’t, the mTLS certificate will not be transferred to Mangopay. When mTLS is enforced, your integration will result in an error.

### Configure the SDK’s mTLS properties

The Python SDK allows you to load the `.pem` and `.key` file paths in the global configuration or in the per-request handler.

    | Property (global / per-request) | Type   | Description                          |
    | ------------------------------- | ------ | ------------------------------------ |
    | `mtls_cert` / `cert`            | string | Path to the certificate `.pem` file. |
    | `mtls_private_key` / `key`      | string | Path to the private `.key` file.     |

**Caution:** The per-request properties `cert` and `key` take precedence if set and the global ones are ignored (`mangopay.mtls_cert` and `mangopay.mtls_private_key`).

The certificate files must be accessible at runtime; the SDK does not validate their content at initialization time.

When both are provided, the SDK sets `session.cert = (cert, key)` on the underlying `requests.Session`. If a combined certificate is provided (bundling the key), the SDK sets `session.cert = cert`.

#### Global configuration

The global properties allow you to set the certificate and key before making any API calls. The certificate is used for all requests made through the default handler.

```python  theme={null}
    import mangopay

    mangopay.client_id = 'your-mangopay-client-id'
    mangopay.apikey = 'your-mangopay-api-key'
    mangopay.api_sandbox_url = 'https://api-mtls.sandbox.mangopay.com/v2.01/'
    sandbox = True
    # mangopay.api_url = 'https://api-mtls.mangopay.com/v2.01/'
    mangopay.mtls_cert = '/path/to/certificate.pem'
    mangopay.mtls_private_key = '/path/to/private.key'
```

#### Per-request handler

**Caution:** The per-request values take precedence over the global values.

Each `APIRequest` instance maintains its own `requests.Session`, so mTLS certificates are scoped to that instance and do not leak between handlers.

```python  theme={null}
    from mangopay.api import APIRequest

    handler = APIRequest(
        client_id='your-mangopay-client-id',
        apikey='your-mangopay-api-key',
        api_sandbox_url = 'https://api-mtls.sandbox.mangopay.com/v2.01/' # mTlS base URL
    	sandbox = True
    	# mangopay.api_url = 'https://api-mtls.mangopay.com/v2.01/'
        cert='/path/to/certificate.pem',
        key='/path/to/private.key'
    )
```

Then pass the handler when making API calls:

```python  theme={null}
    from mangopay.resources import NaturalUser, Wallet

    user = NaturalUser.get(user_id, handler=handler)
    wallet = Wallet.get(wallet_id, handler=handler)
```

License
-------------------------------------------------
MangopaySDK is distributed under MIT license, see LICENSE file.


Inspiration
-----------

The data model of python-mangopay is highly inspired by [peewee](https://github.com/coleifer/peewee).

Credits
-----------

The inital basis of this SDK was generously coded and donated by [Ulule](https://www.ulule.com/)

