Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rostyq/liqpy
Unofficial python library for LiqPay API
https://github.com/rostyq/liqpy
liqpay liqpay-api liqpay-sdk python-liqpay
Last synced: about 2 months ago
JSON representation
Unofficial python library for LiqPay API
- Host: GitHub
- URL: https://github.com/rostyq/liqpy
- Owner: rostyq
- License: mit
- Created: 2023-10-24T15:01:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-08T13:11:41.000Z (10 months ago)
- Last Synced: 2024-11-16T01:39:39.555Z (about 2 months ago)
- Topics: liqpay, liqpay-api, liqpay-sdk, python-liqpay
- Language: Python
- Homepage: https://pypi.org/project/liqpy
- Size: 140 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LiqPy
LiqPy -- unofficial python library for [LiqPay API](https://www.liqpay.ua/documentation/api/home).
> _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
```shell
pip install liqpy
```## Basic Usage
Create checkout link:
```python
from liqpy.client import Clientclient = Client(public_key=..., private_key=...)
client.checkout(
action="pay",
order_id=...,
amount=1,
currency="USD",
description="Payment Example",
server_url=...
)
```Handle [callback from LiqPay](https://www.liqpay.ua/en/documentation/api/callback) after checkout on your server (`server_url`):
```python
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):
```shell
python -m env env
```Install requirements:
```shell
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:
```shell
LIQPAY_PUBLIC_KEY=${public_key}
LIQPAY_PRIVATE_KEY=${private_key}
```### Local webhook handler
Bind localhost port to the Internet:
```shell
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:
```shell
python -m tests.server
```Now you can recieve callbacks after requesting LiqPay API.
```python
from os import environ
from dotenv import load_env
from liqpay.client import Clientclient = Client()
client.request(
action=...,
order_id=...,
amount=...,
server_url=environ.get("SERVER_URL")
)
```See [`readme.ipynb`](./readme.ipynb) for more examples.