Skip to main content

Mangopay Python SDK

MangopaySDK is a Python client library to work with Mangopay REST API.

Installation

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

To install the package:

    pip install mangopay4-python-sdk

By installing this package with pip, all dependencies will be installed for you.

Development install

The project is managed with Poetry. 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

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.

    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.

    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:

    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.

Credits

The inital basis of this SDK was generously coded and donated by Ulule

Metadata

Release files for mangopay4-python-sdk 4.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mangopay4-python-sdk 4.0.1
File Size Uploaded
mangopay4_python_sdk-4.0.1.tar.gz 58.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mangopay4-python-sdk 4.0.1
File Interpreter ABI Platform
mangopay4_python_sdk-4.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 119.0 kB

Release files / mangopay4_python_sdk-4.0.1.tar.gz

Download URL mangopay4_python_sdk-4.0.1.tar.gz
Size 58.3 kB
Tags Source
SHA-256 checksum
How to use checksums
82fef556ca4986f73ed82da5711f1053d0c1de8a29c616876ae666d607c7a3e4
BLAKE2b-256 checksum
How to use checksums
ec3e9ad7c87792f93aafe2b406b826a0c5ac2080b45e291c2a7f7f697f9970cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.12.94-123.190.amzn2023.x86_64

Release files / mangopay4_python_sdk-4.0.1-py3-none-any.whl

Download URL mangopay4_python_sdk-4.0.1-py3-none-any.whl
Size 60.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
363c78257c4c48a37d566abb21e55566e4e74ab08d52bef26b16e799ea7a2a76
BLAKE2b-256 checksum
How to use checksums
02fc053800a801a31f48dc667e240e3692bbacaa7f89acae790a7a32ba4bb500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.12.94-123.190.amzn2023.x86_64

Release history Release notifications | RSS feed

4.2.0

2 release files

4.1.0

2 release files

This release

4.0.1 This release

2 release files

4.0.0

2 release files

3.59.0

2 release files

3.58.0

2 release files

3.57.0

2 release files

3.56.0

2 release files

3.55.0

2 release files

3.54.1

2 release files

3.54.0

2 release files

3.53.0

2 release files

3.52.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page