Unofficial Python libary for LiqPay API
Project description
LiqPy
LiqPy -- unofficial python library for LiqPay API.
Is it production ready?
Short answer: Well, yes, but actually no.
Long answer: It depends on what production readiness means for you. Implementation still lacks some LiqPay's functionality and tests coverage, but I, personally, use it in production. It gets work done in a most pythonic way I see it.
Installation
pip install liqpy
Basic Usage
Create checkout link:
from liqpy.client import Client
client = Client(public_key=..., private_key=...)
client.checkout(
action="pay",
order_id=...,
amount=1,
currency="USD",
description="Payment Example",
server_url=...
)
Handle callback from LiqPay after checkout on your server (server_url
):
def handle_callback(data: str, signature: str):
try:
callback = client.callback(data, signature)
print(callback)
except AssertionError as e:
print("LiqPay callback verification failed.", e)
Development
Create Python environment (optional):
python -m env env
Install requirements:
pip install -r requirements.txt -r requirements-dev.txt
Setup credentials
Get your public_key
and private_key
from LiqPay.
Write keys to .env
file as follows:
LIQPAY_PUBLIC_KEY=${public_key}
LIQPAY_PRIVATE_KEY=${private_key}
Local webhook handler
Bind localhost port to the Internet:
ngrok http 8000
Look for the similar line in console:
Forwarding https://7kh6-111-111-111-111.ngrok-free.app -> http://localhost:8000
Add server URL to .env
file:
SERVER_URL=https://7kh6-111-111-111-111.ngrok-free.app
Start local webhook handler:
python -m tests.server
Now you can recieve callbacks after requesting LiqPay API.
from os import environ
from dotenv import load_env
from liqpay.client import Client
client = Client()
client.request(
action=...,
order_id=...,
amount=...,
server_url=environ.get("SERVER_URL")
)
See readme.ipynb
for more examples.
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
File details
Details for the file liqpy-0.16.0.tar.gz
.
File metadata
- Download URL: liqpy-0.16.0.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7cfa3e115f67162be09c6310674234798af25e6d8d123d989f4af7f93d5c49 |
|
MD5 | 17f193c3851a4177c2d20370bdeabb9d |
|
BLAKE2b-256 | 012c9b52deaefcbdeccf458b3f124541b354bce6b15b242be1aa45d809cc4582 |
File details
Details for the file liqpy-0.16.0-py3-none-any.whl
.
File metadata
- Download URL: liqpy-0.16.0-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 421c25c4ba07b0e6053dd9b56cd45c8310d8a670ae36891b6c64e4f2c37c82f2 |
|
MD5 | 76d7f53fe6abbdc05e20c893c67cd104 |
|
BLAKE2b-256 | adaded6ddbf7f9411e49e1a624a52e4d905b188cf29cb526103541afe6f4d04a |