Metadata-Version: 2.4
Name: liqpy
Version: 0.20.0
Summary: Unofficial Python libary for LiqPay API
Project-URL: Repository, https://github.com/rostyq/liqpy
Author-email: Rostyslav Bohomaz <rostyslav.db@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Rostyslav Bohomaz
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: api,liqpay
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Requires-Dist: httpx>=0.28.0
Description-Content-Type: text/markdown

# LiqPy

LiqPy -- unofficial python library for [LiqPay API](https://www.liqpay.ua/doc).

> _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

Get `public_key` and `private_key` from LiqPay and create a checkout link:

```python
from liqpy.client import Client

# env variables for keys are LIQPAY_PUBLIC_KEY and LIQPAY_PRIVATE_KEY
client = Client(public_key=..., private_key=...)

checkout_link = client.checkout(
    action="pay",
    order_id=...,
    amount=1,
    currency="USD",
    description="Payment Example",
    # set server_url for handling a callback
    # server_url=...
)
print(checkout_link)
```

## Handle Callback

Handle [callback from LiqPay](https://www.liqpay.ua/en/doc/api/callback) after checkout on your server (`server_url`):

```python
from urllib.parse import parse_qs
from liqpy.api.exceptions import LiqPayRequestException

# request body content type is application/x-www-form-urlencoded
def handle_callback(body: str):
    query = parse_qs(body)
    data, signature = query["data"][0], query["signature"][0]
    try:
        result = client.callback(data, signature)
        print(result)
    except LiqPayRequestException:
        print("LiqPay callback verification failed.")
```

See [`readme.ipynb`](./readme.ipynb) for more examples.
