Skip to main content

Unofficial Python libary for LiqPay API

Project description

LiqPy

LiqPy -- unofficial python library for LiqPay API.

Installation

pip install liqpy

Basic Usage

Create checkout link:

from uuid import uuid4
from liqpy.client import Client

client = Client(public_key=..., private_key=...)

client.checkout(
    action="pay",
    order_id=str(uuid4()),
    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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

liqpy-0.3.0.tar.gz (12.5 kB view hashes)

Uploaded Source

Built Distribution

liqpy-0.3.0-py3-none-any.whl (12.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page