Official Python SDK for the Finswitz API
Project description
Finswitz Python SDK
Python client for the Finswitz API.
Installation
The Python SDK is currently distributed as a source client. Add finswitz.py to your application package, then import Finswitz.
When a package is published, this README should be updated with the package manager install command.
Requirements
- Python 3.9 or newer
- A Finswitz test or live secret key
Quick Start
import os
from finswitz import Finswitz
client = Finswitz(api_key=os.environ["FINSWITZ_SECRET_KEY"])
link = client.create_payment_link(
{
"amount": 5000,
"currency": "NGN",
"title": "Order #1234",
"email": "buyer@example.com",
"callback_url": "https://merchant.example/complete",
},
idempotency_key="order-1234-link",
)
print(link["checkoutUrl"])
Custom Base URL
client = Finswitz(
api_key=os.environ["FINSWITZ_SECRET_KEY"],
base_url="http://localhost:4000",
)
Payments
client.transfer(
{
"amount": 5000,
"currency": "NGN",
"bank_code": "058",
"account_number": "0123456789",
"narration": "Vendor payout",
},
idempotency_key="transfer-001",
)
client.mobile_money(
{
"amount": 1500,
"currency": "GHS",
"phone": "+233501112222",
"country": "GH",
},
idempotency_key="momo-001",
)
transaction = client.get_transaction("reference")
Dashboard JWT Helpers
client = Finswitz(
api_key=os.environ["FINSWITZ_SECRET_KEY"],
dashboard_token=os.environ["FINSWITZ_DASHBOARD_TOKEN"],
)
client.update_webhooks(
{
"mode": "test",
"url": "https://merchant.example/webhooks/finswitz",
}
)
wallets = client.wallets()
treasury = client.treasury()
Collections
collection = client.public_collection("school-fees")
payment = client.pay_collection(
"school-fees",
{
"fullName": "Grace Johnson",
"email": "grace@example.com",
"amount": 10000,
"phone": "+2348012345678",
},
)
Error Handling
from finswitz import FinswitzApiError
try:
client.get_transaction("missing-reference")
except FinswitzApiError as error:
print(error.status)
print(error.response)
raise
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
finswitz-1.0.0.tar.gz
(3.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file finswitz-1.0.0.tar.gz.
File metadata
- Download URL: finswitz-1.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5175cec054d76b2cccdd23b697e7039c8b746b534766965830d7bd1724b92a3f
|
|
| MD5 |
27bd95f18294b9a5138a430d54153b15
|
|
| BLAKE2b-256 |
b067b2bf7ab271311ee97c926bc211a24beb8b295e256b47cede1266d414a3ca
|
File details
Details for the file finswitz-1.0.0-py3-none-any.whl.
File metadata
- Download URL: finswitz-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ac6b98748c28497b48245bff54f4f9a0424d27e6c3d585fb917670f5b9caeae
|
|
| MD5 |
7bd1a3591fcab1d9ae8110d365ffc45f
|
|
| BLAKE2b-256 |
ddd6e834718cc8d867d423598a61e999b50ebeaf21c494c02a36bc1c631b14fb
|