Setu UPI DeepLinks: Python SDK
setu is a Python SDK for accessing Setu’s UPI Deeplinks APIs. The SDK is designed with ease of access in mind, with native Python class objects for inputs & ouputs and custom exceptions.
Getting started
SDK documentation →
Full documentation →
Product overview →
Installation
pip install setu
Features
- Full support for latest UPI Deeplinks APIs
- Native Python class objects for all inputs & responses
- Allows both JWT & OAuth authentication mechanisms
SANDBOXmode to test integration &PRODUCTIONfor live data- Internal mechanism for OAuth authentication to automatically re-fetch token when current one expires, and retry all failed requests.
Examples
Setup
from setu import Deeplink
from setu.contract import RefundRequestItem, SetuAPIException
dl = Deeplink(
scheme_id="c4f57443-dc1e-428f-8c4e-e5fd531057d2",
secret="5b288618-473f-4193-ae1b-8c42f223798e",
product_instance_id="861023031961584801",
auth_type="OAUTH",
mode="SANDBOX",
)
Generate UPI payment link
bill_amount = 100
try:
link = dl.create_payment_link(
amount_value=bill_amount,
biller_bill_id="test_transaction_1234",
amount_exactness="EXACT",
payee_name="Python SDK unittest",
transaction_note="unittest transaction",
)
assert link.payment_link.upi_id == "refundtest@kaypay"
except SetuException as e:
assert False
Get Payment Link Status
try:
link_status = dl.check_payment_status(link.platform_bill_id)
assert link_status.status == "BILL_CREATED"
except SetuAPIException as e:
assert False
Trigger mock payment for UPI payment link (Sandbox only)
try:
credit_response = dl.trigger_mock_payment(
float(bill_amount) / 100, link.payment_link.upi_id, link.platform_bill_id
)
except SetuAPIException as e:
assert False
Mock Settlement
try:
dl.trigger_mock_settlement([credit_response.utr])
except SetuAPIException as e:
assert False
Expire bill payment
try:
dl.expire_payment_link(link.platform_bill_id)
except SetuAPIException as e:
assert False
Initiate Refund
try:
batch_initiate_refund_response = dl.initiate_batch_refund(
refunds=[
RefundRequestItem(
identifier=link.platform_bill_id,
identifierType="BILL_ID",
refundType="FULL",
),
],
)
assert batch_initiate_refund_response.refunds[0].status == "Pending"
except SetuAPIException as e:
assert False
Get refund batch status
try:
refund_batch_status_response = dl.get_batch_refund_status(batch_initiate_refund_response.batch_id)
assert refund_batch_status_response.refunds[0].bill_id == link.platform_bill_id
except SetuAPIException as e:
assert False
Get individual refund status
try:
refund_status_response = dl.get_refund_status(batch_initiate_refund_response.refunds[0].id)
assert refund_status_response.bill_id == link.platform_bill_id
except SetuAPIException as e:
assert False
Contributing
Have a look through existing Issues and Pull Requests that you could help with. If you'd like to request a feature or report a bug, please create a GitHub Issue using the template provided.
Credits
This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.
License
MIT. Have at it.
Metadata
Release files for setu 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| setu-2.1.0.tar.gz | 12.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| setu-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.4 kB
Release files / setu-2.1.0.tar.gz
| Download URL | setu-2.1.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3240d17a00647dea37916be7cd47690b08d891cee8d4123e0e53653cdc25e7e3
|
|
BLAKE2b-256 checksum How to use checksums |
3da788bb4818ad5812d8bc3a87d8327d09abcee72da18ec298d73c69d3640871
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Release files / setu-2.1.0-py3-none-any.whl
| Download URL | setu-2.1.0-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
276b14ca9ebcaabb3b4bd54c684b842e90cf398aa2f4597eb23c5a325f829ba6
|
|
BLAKE2b-256 checksum How to use checksums |
9c39537eda49efefd735774108dcee32bd67701fcecf96c8934c5544a51720e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Security for setu 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.