Skip to main content

SDK for UniPay.com payment gateway

Reason this release was yanked:

Broken

Project description

unipay-sdk

Python SDK for unipay.com payments gateway

Install

pip3 install unipay-sdk

How to ...

Create order

from unipay_sdk import UniPayClient
from unipay_sdk import OrderItem

client = UniPayClient(
    secretkey='mySecretKeyFromUniPay',
    merchant_id=00000000000000,
    success_url='/url/success',
    cancel_url='/url/cancel',
    callback_url='/url/callback'
)

new_order = client.create_order(
    merchant_order_id='ORDER1234', # Unique order id
    merchant_order_user='1', # User id on merchant side
    order_price=15.35, # in GEL
    order_name='Purchase on example.com',
    order_description='Some description',
    items=[
        OrderItem.from_dict({'price': 7.0, 'quantity': 1, 'title': 'Coffee', 'description': 'Cup of coffee'}),
        OrderItem.from_dict({'price': 8.35, 'quantity': 1, 'title': 'Cake', 'description': 'Big cake'})        
    ]
)
checkout_link = new_order.data.Checkout
order_hash = new_order.data.UnipayOrderHashID

Handle errors

from unipay_sdk import UniPayClient
from unipay_sdk import OrderItem
from unipay_sdk import APIError

client = UniPayClient(...)

new_order = client.create_order(...)

match new_order.errorcode:
    case APIError.OK:
        print('OK')
    case APIError.FREQUENCY_LIMIT_EXCEEDED:
        print('Rate limited')
    # etc...

Test server

To test order workflows you may use unipay-test-server

To use test server you might initialize UniPayClient with test flag

from unipay_sdk import UniPayClient

test_client = UniPayClient(..., test=True, test_url='http://localhost:8080')
# test_url is path to unipay-test-server 

Validate

UniPay-SDK also provides Pydantic 2.0 schemas for callbacks and responses

from unipay_sdk.pydantic import BasicUniPayCallback
from unipay_sdk.pydantic import BasicUniPayResponse

Found error or want to contribute?

You may create a pull request to repository

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

unipay_sdk-0.0.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

unipay_sdk-0.0.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file unipay_sdk-0.0.2.tar.gz.

File metadata

  • Download URL: unipay_sdk-0.0.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for unipay_sdk-0.0.2.tar.gz
Algorithm Hash digest
SHA256 795957fcb115adc97fd069b274ca568396800a76e4527fe4d6bac366b459b769
MD5 fa1cd2a05319f765dfb395beb11a83ff
BLAKE2b-256 106d7271b13e0655b9830cbb29393425da0e25abeb9fc5ebc0e730681bff7caa

See more details on using hashes here.

File details

Details for the file unipay_sdk-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: unipay_sdk-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for unipay_sdk-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 746acbe4c0de720a08addb0b80962e35dc48925fb4c37b6001d9253503d53a10
MD5 81a35611bd5ae4c36e1e7ee4ca5c4e8f
BLAKE2b-256 1db1b783837b02043ae1fd9c6a6df16505344038a941b02f73cb121d451f59f7

See more details on using hashes here.

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