Skip to main content

Official Python SDK for the BixyPay Fintech API Platform

Project description

BixyPay Fintech API - Python SDK

Official Python SDK for the BixyPay Fintech API Platform. This SDK provides a simple and intuitive interface for integrating crypto-fiat payment processing into your Python applications.

Installation

pip install bixypay-sdk

Or install from source:

git clone https://github.com/bixypay/fintech-sdk-python
cd fintech-sdk-python
pip install -e .

Quick Start

from bixypay import BixyPayClient

# Initialize with API key
client = BixyPayClient(
    base_url="https://api.bixypay.com",
    api_key="sk_live_your_api_key_here"
)

# Create an invoice
response = client.invoices.create({
    "amount": 100.50,
    "currency": "USD",
    "description": "Payment for Product XYZ"
})

if response["error"]:
    print("Error:", response["error"])
else:
    print("Invoice created:", response["data"])

Authentication

The SDK supports two authentication methods:

1. API Key Authentication (Recommended for server-side)

client = BixyPayClient(
    base_url="https://api.bixypay.com",
    api_key="sk_live_your_api_key"
)

2. JWT Token Authentication

client = BixyPayClient(
    base_url="https://api.bixypay.com",
    jwt_token="your_jwt_token"
)

Usage Examples

Authentication & Registration

Register a New Merchant

response = client.auth.register(
    email="merchant@example.com",
    password="SecurePassword123!",
    business_name="My Business LLC",
    business_address="123 Business Street"
)

Login and Get JWT Token

response = client.auth.login(
    email="merchant@example.com",
    password="SecurePassword123!"
)

if not response["error"]:
    # Token is automatically stored in client
    access_token = response["data"]["access_token"]
    print(f"Logged in! Token: {access_token}")

Create API Key

client = BixyPayClient(
    base_url="https://api.bixypay.com",
    jwt_token=your_jwt_token
)

response = client.auth.create_api_key(
    name="Production API Key",
    scopes=["invoices:read", "invoices:write"]
)

if not response["error"]:
    api_key = response["data"]["key"]
    print(f"API Key created: {api_key}")

Merchant Operations

Get Merchant Profile

response = client.merchants.get_profile()

if not response["error"]:
    profile = response["data"]
    print(f"Business: {profile['businessName']}")
    print(f"KYC Status: {profile['kycStatus']}")

Get Account Balance

response = client.merchants.get_balance()

if not response["error"]:
    balance = response["data"]
    print(f"Balance: {balance['balance']} {balance['currency']}")

Update KYC Status

response = client.merchants.update_kyc_status("approved")

if not response["error"]:
    print("KYC status updated successfully")

Invoice Management

Create an Invoice

response = client.invoices.create({
    "amount": 99.99,
    "currency": "USD",
    "description": "Premium Subscription - Monthly",
    "metadata": {
        "customer_id": "cust_12345",
        "plan": "premium"
    },
    "callbackUrl": "https://yourapp.com/webhooks/payment"
})

if not response["error"]:
    invoice = response["data"]
    print(f"Invoice ID: {invoice['invoiceId']}")  # Use invoiceId for subsequent API calls
    print(f"Payment URL: {invoice['paymentUrl']}")

Get Invoice by ID

response = client.invoices.get("invoice-id-here")

if not response["error"]:
    invoice = response["data"]
    print(f"Status: {invoice['status']}")
    print(f"Amount: {invoice['amount']} {invoice['currency']}")

List Invoices

response = client.invoices.list({
    "page": 1,
    "limit": 20
})

if not response["error"]:
    invoices = response["data"]
    for invoice in invoices:
        print(f"{invoice['invoiceId']} - {invoice['status']} - ${invoice['amount']}")

Update Invoice Status

response = client.invoices.update_status(
    invoice_id="invoice-id-here",
    status="completed",
    tx_hash="0x1234567890abcdef"  # Optional: blockchain transaction hash
)

if not response["error"]:
    print("Invoice status updated successfully")

Webhook Management

Create a Webhook

response = client.webhooks.create(
    url="https://yourapp.com/webhooks/bixypay",
    events=["invoice.created", "invoice.completed", "invoice.failed"]
)

if not response["error"]:
    webhook = response["data"]
    print(f"Webhook ID: {webhook['id']}")

List Webhooks

response = client.webhooks.list()

if not response["error"]:
    webhooks = response["data"]
    for webhook in webhooks:
        print(f"{webhook['id']} - {webhook['url']}")

Delete a Webhook

response = client.webhooks.delete("webhook-id-here")

if not response["error"]:
    print("Webhook deleted successfully")

Error Handling

All SDK methods return a dictionary with data and error keys:

response = client.invoices.create({
    "amount": 100,
    "currency": "USD"
})

if response["error"]:
    error = response["error"]
    print(f"Error: {error.get('message', 'Unknown error')}")
    if "statusCode" in error:
        print(f"HTTP Status: {error['statusCode']}")
else:
    # Success
    invoice = response["data"]
    print(f"Invoice created: {invoice['invoiceId']}")

Dynamic Token Management

You can update authentication tokens dynamically:

client = BixyPayClient(base_url="https://api.bixypay.com")

# Login and get JWT token
login_response = client.auth.login("user@example.com", "password")

# Create API key using JWT
api_key_response = client.auth.create_api_key("My API Key")

# Switch to API key authentication
client.set_api_key(api_key_response["data"]["key"])

# Now use API key for subsequent requests
balance = client.merchants.get_balance()

Type Hints

This SDK includes comprehensive type hints for better IDE support and type checking:

from bixypay import BixyPayClient
from bixypay.types import CreateInvoiceRequest, ListInvoicesParams

invoice_data: CreateInvoiceRequest = {
    "amount": 100.0,
    "currency": "USD",
    "description": "Test payment"
}

response = client.invoices.create(invoice_data)

Requirements

  • Python 3.7+
  • requests >= 2.28.0

Support

License

MIT License - see LICENSE file 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

bixypay_sdk-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bixypay_sdk-1.0.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file bixypay_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: bixypay_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for bixypay_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b408f0f33221d54e97ffb56a166debaaa1ff492aa6357b4e571504828002ea8d
MD5 abf274f162c30c8747804f733564ace4
BLAKE2b-256 2941356818789356d6fc381b4e16bd64fe99a3537a5eaaa666e96eba838e7782

See more details on using hashes here.

File details

Details for the file bixypay_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bixypay_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for bixypay_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60f8e40ffe35087afdcc1005b1ab1ccd74f2dbbee13dd78c78b80f2d0754d2cc
MD5 4be9d3835b8a7e3e784333e76cc39b7e
BLAKE2b-256 c9f84a3ca7db58cb7a7f70d58e0546d017e46af3bfc58d04633623164a7450ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page