Giter Site home page Giter Site logo

liqpy's Introduction

LiqPy

LiqPy -- unofficial python library for LiqPay API.

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

pip install liqpy

Basic Usage

Create checkout link:

from liqpy.client import Client

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

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

liqpy's People

Contributors

rostyq avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.