Official Python SDK for InventPay - Accept crypto payments with ease
Project description
InventPay Python SDK
The official Python SDK for InventPay - Accept crypto payments, manage stores, handle withdrawals, and receive real-time notifications with ease.
Features
- 💳 Accept Crypto Payments - Bitcoin, Ethereum, Litecoin, USDT (ERC20 & BEP20)
- 🏪 Store Management - Create storefronts, add digital products, manage orders
- 🔄 Secure Withdrawals - Withdraw funds with a dedicated withdrawal API key
- 💰 Balance Tracking - Real-time balance and limit monitoring
- 🔔 Webhook Support - Secure payment notifications and event handling
- 🎯 Dual Payment Modes - Fixed currency or multi-currency invoices
- 🐍 Pythonic API - Full type hints and dataclass support
- ⚡ Lightweight - Minimal dependencies (only
requests)
Installation
pip install inventpay
Quick Start
import os
from inventpay import PaymentSDK, SDKConfig
# Initialize with your API key
sdk = PaymentSDK(SDKConfig(
api_key=os.getenv("INVENTPAY_API_KEY"),
withdrawal_api_key=os.getenv("INVENTPAY_WITHDRAWAL_KEY"), # Optional
))
# Test the connection
result = sdk.test_connection()
print(result["message"]) # "API connection successful"
Accepting Payments
Option 1: Fixed Currency Payment
from inventpay import PaymentRequest
payment = sdk.create_payment(PaymentRequest(
amount=29.99,
currency="USDT_BEP20",
order_id="order-12345",
description="Premium Plan",
))
print(f"Payment ID: {payment.data['paymentId']}")
print(f"Address: {payment.data['address']}")
print(f"Invoice URL: {payment.data['invoiceUrl']}")
Option 2: Multi-Currency Invoice
from inventpay import InvoiceRequest
invoice = sdk.create_invoice(InvoiceRequest(
amount=49.99,
order_id="order-67890",
description="E-commerce Purchase",
))
print(f"Invoice URL: {invoice.data['invoiceUrl']}")
Check Payment Status
status = sdk.get_payment_status("your-payment-id")
print(f"Status: {status.status}") # PENDING, COMPLETED, EXPIRED, FAILED
Managing Balances
# Get all balances
balances = sdk.get_balances()
for currency, info in balances.data["balances"].items():
print(f"{currency}: {info['availableBalance']} available")
# Get specific currency balance
usdt = sdk.get_balance("USDT_BEP20")
print(f"USDT: {usdt.data['balance']['availableBalance']}")
Withdraw Funds
Programmatic withdrawals require a Withdrawal API Key — a separate key from your main API key, disabled by default for security.
- Go to Dashboard → Settings → Withdrawal API Key
- Click "Generate Key" to create your
wk_live_...key - Pass it when initializing the SDK
sdk = PaymentSDK(SDKConfig(
api_key=os.getenv("INVENTPAY_API_KEY"),
withdrawal_api_key=os.getenv("INVENTPAY_WITHDRAWAL_KEY"),
))
from inventpay import WithdrawalRequest
withdrawal = sdk.create_withdrawal(WithdrawalRequest(
amount=10.0,
currency="USDT_BEP20",
destination_address="0x1E3D6848dE165e64052f0F2A3dA8823A27CAc22D",
description="Monthly payout",
))
print(f"Withdrawal ID: {withdrawal.data['withdrawalId']}")
print(f"Status: {withdrawal.data['status']}")
Note: If
withdrawal_api_keyis not provided,create_withdrawal()will raise aPaymentSDKError.
Store Management
Create and manage digital storefronts with products and orders.
Create a Store
from inventpay import CreateStoreRequest
store = sdk.create_store(CreateStoreRequest(
name="My Digital Shop",
description="Premium digital products",
))
print(f"Store slug: {store.data['slug']}")
# Store URL: https://inventpay.io/store/{slug}
Add Products
from inventpay import CreateProductRequest
product = sdk.create_product(CreateProductRequest(
name="Premium Template Pack",
price=29.99,
currency="USD",
description="50+ professional templates",
stock=100,
digital_content={
"fileUrl": "https://yourstorage.com/templates.zip",
"instructions": "Download link valid for 24 hours",
},
))
List Products
products = sdk.list_products(page=1, limit=20)
for p in products.data["products"]:
print(f"{p['name']} - ${p['price']}")
Manage Orders
# List orders
orders = sdk.list_orders(status="PAID", limit=10)
# Get order details
order = sdk.get_order("order-id")
# Update fulfillment status
sdk.update_order_status("order-id", "COMPLETED")
Update & Delete Products
from inventpay import UpdateProductRequest
sdk.update_product("product-id", UpdateProductRequest(price=24.99, stock=50))
sdk.delete_product("product-id")
Webhook Handling
Configure Webhooks
from inventpay import WebhookConfig
sdk.configure_webhook(WebhookConfig(
webhook_url="https://yourapp.com/webhooks/inventpay"
))
Flask Webhook Handler
from flask import Flask, request, jsonify
from inventpay import verify_webhook_signature
app = Flask(__name__)
WEBHOOK_SECRET = "your-webhook-secret-from-dashboard"
@app.route("/webhooks/inventpay", methods=["POST"])
def handle_webhook():
signature = request.headers.get("X-Webhook-Signature")
payload = request.get_json()
if not verify_webhook_signature(payload, signature, WEBHOOK_SECRET):
return jsonify({"error": "Invalid signature"}), 401
event_type = payload.get("event")
if event_type == "payment.completed":
print(f"Payment completed: {payload['data']['paymentId']}")
return jsonify({"received": True})
Error Handling
from inventpay import PaymentSDKError, AuthenticationError, ValidationError
try:
payment = sdk.create_payment(PaymentRequest(amount=25, currency="USDT_BEP20"))
except AuthenticationError as e:
print(f"Invalid API key: {e.message}")
except ValidationError as e:
print(f"Invalid request: {e.message} - {e.details}")
except PaymentSDKError as e:
print(f"API error: {e.message} (Status: {e.status_code})")
API Reference
Payment Methods
| Method | Description |
|---|---|
create_payment() |
Create fixed currency payment |
create_invoice() |
Create multi-currency invoice |
get_payment_status() |
Check payment status |
Balance Methods
| Method | Description |
|---|---|
get_balances() |
Get all currency balances |
get_balance(currency) |
Get specific currency balance |
Withdrawal Methods
| Method | Description |
|---|---|
create_withdrawal() |
Create withdrawal (requires key) |
get_withdrawal() |
Check withdrawal status |
Store Methods
| Method | Description |
|---|---|
create_store() |
Create a new store |
get_store() |
Get store details |
update_store() |
Update store settings |
create_product() |
Add a product |
list_products() |
List all products |
update_product() |
Update a product |
delete_product() |
Delete (deactivate) a product |
list_orders() |
List store orders |
get_order() |
Get order details |
update_order_status() |
Update order status |
Webhook Methods
| Method | Description |
|---|---|
configure_webhook() |
Set webhook URL |
get_webhook_config() |
Get webhook configuration |
test_webhook() |
Test webhook endpoint |
get_webhook_deliveries() |
Get delivery history |
get_webhook_stats() |
Get delivery statistics |
delete_webhook() |
Remove webhook configuration |
Configuration
config = SDKConfig(
api_key="your-api-key", # Required
withdrawal_api_key="wk_live_...", # Optional — for programmatic withdrawals
base_url="https://api.inventpay.io", # Optional
timeout=30, # Optional (seconds)
)
Supported Currencies
BTC- BitcoinETH- EthereumLTC- LitecoinUSDT_ERC20- USDT on EthereumUSDT_BEP20- USDT on Binance Smart Chain
Support
- Documentation: https://docs.inventpay.io
- Dashboard: https://inventpay.io/dashboard
- Email Support: support@inventpay.io
License
MIT License - see LICENSE for details.
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
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 inventpay-1.1.0.tar.gz.
File metadata
- Download URL: inventpay-1.1.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e26b2e866cf2211faaba8bc2b15f65976cce0578c516c089a02e0ba9ffec398
|
|
| MD5 |
5f8c5d4c148ed22cf2e4bcd65e41a8be
|
|
| BLAKE2b-256 |
2649df9a55d378144d5bd2a9da69161122452347518e26ebe3796002960ff556
|
File details
Details for the file inventpay-1.1.0-py3-none-any.whl.
File metadata
- Download URL: inventpay-1.1.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eba286c0a18754003df0cf9340b365ee8d74f32ba6be90a66573e6d597b69c2
|
|
| MD5 |
cd6032bdbb0445cbc824e6f677996ddd
|
|
| BLAKE2b-256 |
b310b18dcf9c01b1b1bbce2a54d26e8624eb576c1028391d23635ac0cc7242f0
|