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.8.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

payrex_python-1.7.8-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: payrex_python-1.7.8.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for payrex_python-1.7.8.tar.gz
Algorithm Hash digest
SHA256 f04f3d317fa767f4de1360ffceb1fe33e6e63f1200ea89a82f6e3ff1edf9e6a9
MD5 ca694f2f0079b072839023b1acfb7e8b
BLAKE2b-256 c1024b187a3c24517daa2140a6c2ce58aa2ce4a811154e04944444e1af286675

See more details on using hashes here.

File details

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

File metadata

  • Download URL: payrex_python-1.7.8-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for payrex_python-1.7.8-py3-none-any.whl
Algorithm Hash digest
SHA256 74e39f287b24870f34bbc8a245c7b9eb29d1dfef96756795a4664df7fe28c7f0
MD5 41b335da3c81541259bfda95573a1c35
BLAKE2b-256 8fc9d50155288a7d5aec265e6d70ac47b0faf2cff9864ec3d41f1171cccc4955

See more details on using hashes here.

Supported by

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