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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file payrex_python-1.7.4.tar.gz.
File metadata
- Download URL: payrex_python-1.7.4.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5934f7c43fced9cc7dc0bec4b9ed72c24dd5d9064918e050547c1a696f8caa9
|
|
| MD5 |
69f9cb2b90f3cb3a58017c11fc886d01
|
|
| BLAKE2b-256 |
506b8156879f3e9a1fa4304ea2761686412c2cca75d6b05fa704ebd507b1dc64
|
File details
Details for the file payrex_python-1.7.4-py3-none-any.whl.
File metadata
- Download URL: payrex_python-1.7.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73e4aad07603a0ec12901324c01fcc810150ebb5d631026d26e13e337c79af5f
|
|
| MD5 |
c81181c3f2234d4e176ccb8423f12001
|
|
| BLAKE2b-256 |
3e7ba47c2f64688e096d359fa26363cbdd3a56c2ec03a8b6ea4211c55973306c
|