LiqPay Async Python3 SDK
Project description
- Web: https://www.liqpay.ua/
- Source: https://github.com/SpaceIgor/liqpay-async
- Documentation: https://www.liqpay.ua/documentation/en/
- Keywords: liqpay, privat24, privatbank, python, internet acquiring, P2P payments, two-step payments
What python version is supported?
- Python 3.4+
Get Started
- Sign up in https://www.liqpay.ua/en/authorization.
- Create a company.
- In company settings, on API tab, get Public key and Private key: https://www.liqpay.ua/doc
- Done.
Installation
From pip
pip install liqpay-async
Working with LiqPay Callback locally
If you need debugging API Callback on local environment use https://localtunnel.github.io/www/
How it uses?
Example 1: Pin token card to user
Backend Get url on SDK
Request url: https://www.liqpay.ua/api/3/checkout
from liqpay_async import LiqPay
liqpay_manager = LiqPay(public_key, private_key)
response = await liqpay_manager.post(
return_url=True,
data={
"action": "hold",
"version": "3",
"amount": "1",
"currency": "UAH", # or any currency
"description": "Pin card",
"language": "uk|en" # liqpay have only ("uk", "en)
"order_id": f"{id_user from token} {str(uuid.uuid4())}", # id_user from token need for pin card to user
"server_url": f"{YOUR_HOST}{URL}", # for callback response
"recurringbytoken": "1", # for get token in response callback
},
)
# check on bad response
if response["status"] in (0, 1):
# when response status 0 or 1 from response dict u can get key 'err_code' - https://www.liqpay.ua/doc/api/errors
raise
# OK response - {"url: url, status: STATUS_MAPPING}
# return url on SDK
# When u sent card credentials in checkout SDK LiqPay. U get response on the url(server_url) from request dict
#Example:
from fastapi import Request, Body
LIQPAY_DOMAIN = "liq_pay domain"
async def pin_card(
request: Request,
liq_pay: YourModel = Body(...),
):
origin = request.headers.get("origin")
if not origin or origin != LIQPAY_DOMAIN: # for security
raise
data = liq_pay.order_id.split()
await liqpay_manager.post(
data={
"action": "refund", # refund money
"version": "3",
"order_id": liq_pay.order_id,
}
)
# and save data from callback
# data[0] - its id user from order_id
# card_token, sender_card_mask2, sender_card_type
Example 2: For other operation by token card
Backend
Request url: https://www.liqpay.ua/api/request
from liqpay_async import LiqPay
liqpay_manager = LiqPay(public_key, private_key)
# https://www.liqpay.ua/doc/api/internet_acquiring/checkout?tab=1
response = await liqpay_manager.post(
data={
"action": "your action",
"version": "3",
"amount": "1",
"currency": "UAH", # or any currency
"description": "Your desc",
"language": "uk|en" # liqpay have only ("uk", "en)
"order_id": "str(uuid.uuid4())",
"card_token": your_card_token
},
)
# OK response - {status: STATUS_MAPPING and others)
Example 3: Errors
Backend
# if response aiothhp error -> response {"status": 0}
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
liqpay-async-0.0.1.tar.gz
(3.4 kB
view details)
File details
Details for the file liqpay-async-0.0.1.tar.gz
.
File metadata
- Download URL: liqpay-async-0.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85dada930ce3ad26a45f43e9fa2fd1b2d3bf7e84feb4641dbe7948f1e8306081 |
|
MD5 | 65ef3f65815e163e614a3dbd8903304f |
|
BLAKE2b-256 | 651f533a8ffc4763e718e679cd93356b9ad79e200f79ed6763e194cda4871f93 |