Python is an interpreted, object-oriented, high-level programming language with dynamic semantics developed by Guido van Rossum. It was originally released in 1991. Designed to be easy as well as fun, the name "Python" is a nod to the British comedy group Monty Python.

You can easily integrate crypto payments into your own website or app with our UniPayment Python SDK, after installation you can start accepting crypto-payments.

UniPayment Python Client

GitHub license PyPI

A Python client for the UniPayment Client API.

This SDK provides a convenient abstraction of UniPayment's Gateway API and allows developers to focus on payment flow/e-commerce integration rather than on the specific details of client-server interaction using the raw API.

Getting Started

Before using the UniPayment API, sign up for your API key.

If you want to use the Sandbox, sign up here.



  1. Download the package and extract it into a local directory or clone the repo.
  2. cd into the root directory where is located.
  3. Enter:
python install

Using pip

pip install unipayment

Initializing UniPayment client

from unipayment import UniPaymentClient

client = unipayment(APP_ID,API_KEY)

Sandbox is used in the same way with is_sandbox as true.

from unipayment import UniPaymentClient

now_pay = unipayment(APP_ID,API_KEY,is_sandbox=True)

Create an invoice


from unipayment import UniPaymentClient, CreateInvoiceRequest

app_id='your app id'
api_key='your api key'

request = CreateInvoiceRequest()
request.title='MacBook Air'
request.description='MacBookAir (256#)'

client = UniPaymentClient(app_id, api_key)
create_invoice_response = client.create_invoice(request)


{'code': 'OK',
 'data': {'address': None,
          'app_id': 'cee1b9e2-d90c-4b63-9824-d621edb38012',
          'confirm_speed': 'Medium',
          'create_time': datetime.datetime(2022, 9, 13, 6, 56, 17),
          'error_status': 'None',
          'exchange_rate': 0.0,
          'expiration_time': datetime.datetime(2022, 9, 13, 7, 1, 17),
          'invoice_id': '6BsP75vBQFvTksa9fNxoEk',
          'invoice_url': '',
          'network': None,
          'order_id': 'your order id',
          'paid_amount': 0.0,
          'pay_amount': 0.0,
          'pay_currency': None,
          'price_amount': 100.2,
          'price_currency': 'USD',
          'status': 'New'},
 'msg': ''}

Handle IPN


Invoice Status:

IPNs (Instant Payment Notifications) are sent to the notify_url when order status is changed to paid, confirmed and complete.

@app.route("/handle-notify", methods=['POST'])
def check_notify():
    notify = request.get_json()
    app_id = 'your app id'
    api_key = 'your api key'

    client = UniPaymentClient(app_id, api_key)
        check_ipn_response = client.check_ipn(notify)
        if check_ipn_response.code == 'OK':
            # ipn is valid, we can handel status
            if notify['status'] == 'Confirmed':
                # payment is confirmed, we can process order here
                print('invoice is confirmed')
            # ipn is not valid
    except ApiException as e:

IPN notify

    "ipn_type": "invoice",
    "event": "invoice_expired",
    "app_id": "cee1b9e2-d90c-4b63-9824-d621edb38012",
    "invoice_id": "3Q7fyLnB2YNhUDW1fFNyEz",
    "order_id": "20",
    "price_amount": 6.0,
    "price_currency": "SGD",
    "network": null,
    "address": null,
    "pay_currency": null,
    "pay_amount": 0.0,
    "exchange_rate": 0.0,
    "paid_amount": 0.0,
    "confirmed_amount": 0.0,
    "refunded_price_amount": 0.0,
    "create_time": "2022-09-12T03:36:03",
    "expiration_time": "2022-09-12T03:41:03",
    "status": "Expired",
    "error_status": "None",
    "ext_args": null,
    "transactions": null,
    "notify_id": "8ccd2b61-226b-48e5-99b8-acb1f350313e",
    "notify_time": "2022-09-12T03:56:10.5852752Z"

Run Example

1.Get source code form GitHub

git clone

2.Prepare the envirement

virtualenv venv
source venv/bin/active
cd UniPaymentClient.Python/UniPaymentClientExample/ pip
pip install -r requrement.txt

3.Run example