Skip to main content

LiqPay Python3 SDK

Project description

Python 3.6+


What python version is supported?

  • Python 3.4+

Get Started

  1. Sign up in
  2. Create a company.
  3. In company settings, on API tab, get Public key and Private key.
  4. Done.


From pip pip install liqpay-sdk-python3

Working with LiqPay Callback locally

If you need debugging API Callback on local environment use

How it uses?

Example 1: Basic

Backend Get payment button (html response)

liqpay = LiqPay(public_key, private_key)
html = liqpay.cnb_form({
    'action': 'pay',
    'amount': '1',
    'currency': 'USD',
    'description': 'description text',
    'order_id': 'order_id_1',
    'version': '3',
    'language': 'ru|uk|en'

Get plain checkout url:

liqpay = LiqPay(public_key, private_key)
html = liqpay.checkout_url({
    'action': 'auth',
    'amount': '1',
    'currency': 'USD',
    'description': 'description text',
    'order_id': 'order_id_1',
    'version': '3',
    'language': 'ru|uk|en',
    'recurringbytoken': '1'
# Response:

str:<decoded data>&signature=<decoded signature>


Variable html will contain next html form

    <form method="POST" action="" accept-charset="utf-8">
         <input type='hidden' name='data' value='eyJhbW91bnQiOi...='/>
         <input type='hidden' name='signature' value='edUs4...='/>
         <button style="border: none !important;display:inline-block !important;text-align: center !important; padding: 7px 20px !important; color: #fff !important;font-size:16px !important; font-weight: 600 !important; font-family:OpenSans, sans-serif;cursor: pointer !important;border-radius: 2px !important;background: rgba(122,183,43,1) !important;"onmouseover=";" onmouseout=";"> <img src="" name="btn_text" style="margin-right: 7px !important; vertical-align: middle !important;"/> 
         <span style="vertical-align:middle;!important">PAY 100 UAH</span>

Example 2: Integrate Payment widget to Django

Payment widget documentation


    from liqpay import LiqPay

    from django.views.generic import TemplateView
    from django.shortcuts import render
    from django.http import HttpResponse

    class PayView(TemplateView):
    template_name = 'billing/pay.html'

    def get(self, request, *args, **kwargs):
        liqpay = LiqPay(settings.LIQPAY_PUBLIC_KEY, settings.LIQPAY_PRIVATE_KEY)
        params = {
            'action': 'pay',
            'amount': '100',
            'currency': 'USD',
            'description': 'Payment for clothes',
            'order_id': 'order_id_1',
            'version': '3',
            'sandbox': 0, # sandbox mode, set to 1 to enable it
            'server_url': '', # url to callback view
        signature = liqpay.cnb_signature(params)
        data = liqpay.cnb_data(params)
        return render(request, self.template_name, {'signature': signature, 'data': data})

    @method_decorator(csrf_exempt, name='dispatch')
    class PayCallbackView(View):
        def post(self, request, *args, **kwargs):
            liqpay = LiqPay(settings.LIQPAY_PUBLIC_KEY, settings.LIQPAY_PRIVATE_KEY)
            data = request.POST.get('data')
            signature = request.POST.get('signature')
            sign = liqpay.str_to_sign(settings.LIQPAY_PRIVATE_KEY + data + settings.LIQPAY_PRIVATE_KEY)
            if sign == signature:
                print('callback is valid')
            response = liqpay.decode_data_from_str(data)
            print('callback data', response)
            return HttpResponse()

    from django.conf.urls import url

    from billing.views import PayView, PayCallbackView

    urlpatterns = [
        url(r'^pay/$', PayView.as_view(), name='pay_view'),
        url(r'^pay-callback/$', PayCallbackView.as_view(), name='pay_callback'),


    <div id="liqpay_checkout"></div>
        window.LiqPayCheckoutCallback = function() {
                data: "{{ data }}",
                signature: "{{ signature }}",
                embedTo: "#liqpay_checkout",
                mode: "embed" // embed || popup,
            }).on("liqpay.callback", function(data){
            }).on("liqpay.ready", function(data){
                // ready
            }).on("liqpay.close", function(data){
                // close
    <script src="//" async></script>

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

liqpay-sdk-python3-1.0.6.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

liqpay_sdk_python3-1.0.6-py3-none-any.whl (6.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