Skip to content

oldnum/liqpay-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

About πŸ“Œ

πŸ’Έ LiqPayApi is a Python SDK for integrating with the LiqPay payment system. It provides functionality to generate payment forms or links, handle callbacks, and check order status, making it easy to integrate LiqPay payments into your applications.

Documentation πŸ’‘

Requirements βš™οΈ

  • Python 3.10+
  • aiohttp

Installation ☁️

pip install liqpay-api

Basic Example ⚑

import asyncio
from liqpay_api.client import LiqPayAsync

async def main():
    # Initialize the client
    liqpay = LiqPayAsync("your_public_key", "your_private_key")
    
    params = {
        "action": "pay",
        "amount": 100,
        "currency": "UAH",
        "description": "Payment for order #123",
        "order_id": "ORDER-123",
        "result_url": "https://your-site.com/success",
        "server_url": "https://your-site.com/liqpay-callback"
    }
    
    # 1. Generate direct checkout URL
    checkout_url = liqpay.generate_checkout_url(params)
    print(f"Checkout URL: {checkout_url}")

    # 2. Get payment URL
    payment_url = await liqpay.get_payment_url(params)
    print(f"Payment URL: {payment_url}")
    
    # 3. Check payment status
    status = await liqpay.get_status("ORDER-123")
    print(f"Payment status: {status.get('status')}")

if __name__ == "__main__":
    asyncio.run(main())

Callback Handling πŸ”—

# Example of handling LiqPay callback (server-to-server)
data = "encoded_data_from_liqpay"
signature = "signature_from_liqpay"

try:
    decoded_params = liqpay.validate_callback(data, signature)
    if decoded_params.get("status") == "success":
        print(f"Order {decoded_params.get('order_id')} paid successfully!")
except ValueError:
    print("Invalid signature!")

Basic methods πŸ› οΈ

  • generate_checkout_url(params): Generates a direct payment link (GET request).
  • get_payment_url(params): Asynchronously performs a POST request and returns the resulting payment URL.
  • generate_cnb_form(params): Returns an HTML form with data and signature for manual redirection.
  • get_status(order_id): Asynchronously checks the status of a specific order.
  • pay(params): Convenience method for direct API payments (action="pay").
  • hold(params): Convenience method for fund blocking (action="hold").
  • subscribe(params): Convenience method for creating recurring payments.
  • validate_callback(data, signature): Decodes and verifies the signature of the incoming LiqPay server-to-server callback.
  • request(endpoint, params): Low-level method for any direct LiqPay API request.

Disclaimer πŸ”°

The information presented here is intended solely for educational and research purposes. It helps to better understand how systems work and how to apply secure practices in software development. πŸ”’

The author does not endorse or encourage the use of this information for illegal purposes 🚨

Use this knowledge responsibly and follow best practices in software development. πŸ‘€

Donation πŸ’°

  • πŸ“’ BTC: bc1qqxzd80fgzqyy4wjfqsweplfmw3av7hxp07eevx
  • πŸ“˜ ETH: 0x20be839c0b9d888e5DD153Cc55A4b93bb8496c48
  • πŸ“— USDT (TRC20): TY6SjeCBE4TRedVCbqk3XLqk5F4UMSGYqw

About

πŸ’Έ LiqPayApi is a Python SDK for integrating with the LiqPay payment system. It provides functionality to generate payment forms or links, handle callbacks, and check order status, making it easy to integrate LiqPay payments into your applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages