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

Uploaded Source

File details

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

File metadata

  • Download URL: payrex_python-0.1.5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for payrex_python-0.1.5.tar.gz
Algorithm Hash digest
SHA256 35bdc7c39dc57264c39557992c076fcb9be12471805dafcfd4f40e11d5041a85
MD5 2f969176c3d77c4d750690e75a22c4b6
BLAKE2b-256 9c8f6afa1fd87ee2fe12b9700c619bd8ade4751d62c9644181b99651f87899b9

See more details on using hashes here.

Supported by

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