payrex-python


Namepayrex-python JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/payrexhq/payrex-python
SummaryPayRex Python Library
upload_time2024-12-04 06:51:45
maintainerNone
docs_urlNone
authorPayRex
requires_pythonNone
licenseMIT
keywords payrex
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PayRex Python

PayRex Python library provides Python applications an easy access to the PayRex API. Explore various Python classes that represents PayRex API resources on object instantiation.

## Requirements

Python 3.9.+

## Installation

If you want to use the package, run the following command:

```sh
pip install payrex-python
```

If you want to build the library from source:

Create a virtual environment

```sh
python -m venv venv
```

Activate the virtual environment

```sh
source venv/bin/activate
```

Install the package to the virtual environment

```sh
pip install -e /Your/Local/Path/payrex-python

python
```

## Getting Started

Simple usage looks like:

```python
from payrex import Client as PayrexClient

payrex_client = PayrexClient('sk_test_...')
payment_intent = payrex_client.payment_intents.retrieve('pi_...')

payment_intent = payrex_client.payment_intents.create(
    {
        'amount': 10000,
        'currency': 'PHP',
        'description': 'Dino Treat',
        'payment_methods': ['gcash']
    }
)
```

## Handle errors

```python
try:
    payrex_client = PayrexClient('sk_test_...')

    payment_intent = payrex_client.payment_intents.create(
        {
            'amount': 10000,
            'description': 'Dino Treat',
            'payment_methods': ['gcash']
        }
    )
except BaseException as e:
    # Handle error
    print(type(e))
    print(e.errors[0].code)
    print(e.errors[0].detail)
    print(e.errors[0].parameter)
```

## Verify webhook signature

```python
try:
    payload = '{"id":"evt_...","resource":"event","type":"payment_intent.succeeded","data":{...'
    signature_header = 't=1715236958,te=,li=...'
    webhook_secret_key = 'whsk_...'

    payrex_client.webhooks.parse_event(
        payload,
        signature_header,
        webhook_secret_key
    )
except SignatureVerificationException as e:
    # Handle invalid signature
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/payrexhq/payrex-python",
    "name": "payrex-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "payrex",
    "author": "PayRex",
    "author_email": "support@payrexhq.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/0c/925ad3770138254e375178d5f6c1263c6a4b9484e3d429fc06ccea8c2073/payrex_python-1.0.2.tar.gz",
    "platform": null,
    "description": "# PayRex Python\n\nPayRex Python library provides Python applications an easy access to the PayRex API. Explore various Python classes that represents PayRex API resources on object instantiation.\n\n## Requirements\n\nPython 3.9.+\n\n## Installation\n\nIf you want to use the package, run the following command:\n\n```sh\npip install payrex-python\n```\n\nIf you want to build the library from source:\n\nCreate a virtual environment\n\n```sh\npython -m venv venv\n```\n\nActivate the virtual environment\n\n```sh\nsource venv/bin/activate\n```\n\nInstall the package to the virtual environment\n\n```sh\npip install -e /Your/Local/Path/payrex-python\n\npython\n```\n\n## Getting Started\n\nSimple usage looks like:\n\n```python\nfrom payrex import Client as PayrexClient\n\npayrex_client = PayrexClient('sk_test_...')\npayment_intent = payrex_client.payment_intents.retrieve('pi_...')\n\npayment_intent = payrex_client.payment_intents.create(\n    {\n        'amount': 10000,\n        'currency': 'PHP',\n        'description': 'Dino Treat',\n        'payment_methods': ['gcash']\n    }\n)\n```\n\n## Handle errors\n\n```python\ntry:\n    payrex_client = PayrexClient('sk_test_...')\n\n    payment_intent = payrex_client.payment_intents.create(\n        {\n            'amount': 10000,\n            'description': 'Dino Treat',\n            'payment_methods': ['gcash']\n        }\n    )\nexcept BaseException as e:\n    # Handle error\n    print(type(e))\n    print(e.errors[0].code)\n    print(e.errors[0].detail)\n    print(e.errors[0].parameter)\n```\n\n## Verify webhook signature\n\n```python\ntry:\n    payload = '{\"id\":\"evt_...\",\"resource\":\"event\",\"type\":\"payment_intent.succeeded\",\"data\":{...'\n    signature_header = 't=1715236958,te=,li=...'\n    webhook_secret_key = 'whsk_...'\n\n    payrex_client.webhooks.parse_event(\n        payload,\n        signature_header,\n        webhook_secret_key\n    )\nexcept SignatureVerificationException as e:\n    # Handle invalid signature\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PayRex Python Library",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/payrexhq/payrex-python"
    },
    "split_keywords": [
        "payrex"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82fb30e85f8c8c6ff1b87cb5b5f9cb675aa69dbd56047ae46762c2e2a58306ac",
                "md5": "1133b97636569cdb1b3d859eb764c162",
                "sha256": "4d6a9ec0bac7fcae6498a87806047e4f961a5b0d00e20181477d2478e8280517"
            },
            "downloads": -1,
            "filename": "payrex_python-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1133b97636569cdb1b3d859eb764c162",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16493,
            "upload_time": "2024-12-04T06:51:43",
            "upload_time_iso_8601": "2024-12-04T06:51:43.297696Z",
            "url": "https://files.pythonhosted.org/packages/82/fb/30e85f8c8c6ff1b87cb5b5f9cb675aa69dbd56047ae46762c2e2a58306ac/payrex_python-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c0c925ad3770138254e375178d5f6c1263c6a4b9484e3d429fc06ccea8c2073",
                "md5": "4064c9140e2306c83aec58672fc893ed",
                "sha256": "7066336f789c27a1874d06a954a5b1c4cdd33f0edc51635308afa7dab2378cd9"
            },
            "downloads": -1,
            "filename": "payrex_python-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4064c9140e2306c83aec58672fc893ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8972,
            "upload_time": "2024-12-04T06:51:45",
            "upload_time_iso_8601": "2024-12-04T06:51:45.398062Z",
            "url": "https://files.pythonhosted.org/packages/4c/0c/925ad3770138254e375178d5f6c1263c6a4b9484e3d429fc06ccea8c2073/payrex_python-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-04 06:51:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "payrexhq",
    "github_project": "payrex-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "payrex-python"
}
        
Elapsed time: 0.37361s