Skip to main content

PayRex Python Library

Project description

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:

pip install payrex-python

If you want to build the library from source:

Create a virtual environment

python -m venv venv

Activate the virtual environment

source venv/bin/activate

Install the package to the virtual environment

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

python

Getting Started

Simple usage looks like:

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

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

payrex_python-1.7.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

payrex_python-1.7.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file payrex_python-1.7.1.tar.gz.

File metadata

  • Download URL: payrex_python-1.7.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for payrex_python-1.7.1.tar.gz
Algorithm Hash digest
SHA256 05af9139bd9b1e412dbf277aa2b290d995c6fd319874b9cadc104cfa903eaf86
MD5 b5ecfdef6714930a8edca51f80311858
BLAKE2b-256 f9a745818425fa9fbc64c4c4de0783bec453f3176713f5427d2e92292d8363d9

See more details on using hashes here.

File details

Details for the file payrex_python-1.7.1-py3-none-any.whl.

File metadata

  • Download URL: payrex_python-1.7.1-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for payrex_python-1.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd974dc63174b60478e701f00f5a3ddd5da42d3022938d59a2edb603b25bda28
MD5 04a7cf5eafb25335765667a5bf4b5d10
BLAKE2b-256 3793bdf7f50a8d869c955575ef6b0a59959db0b17b0390859f9443a2d99a67e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page