Skip to main content

Python SDK for AI Agent Payment Network - Hybrid crypto + fiat payments

Project description

Agent Payment Network SDK

Python SDK for integrating with the AI Agent Payment Network - enabling hybrid crypto + fiat payments for AI agents.

Installation

pip install agent-payment-sdk

Or install from source:

git clone https://github.com/SuryaRaut/agent-payment-network
cd agent-payment-network/sdk/python
pip install -e .

Quick Start

from agent_payment_sdk import AgentPaymentClient

# Initialize client
client = AgentPaymentClient(
    api_key="your_api_key_here",  # Optional for testing
    base_url="http://localhost:8000"
)

# Create a payment
payment = client.create_payment(
    to_agent_id="agent_456",
    amount=50.00,
    currency="USD",
    payment_method="stripe_card",  # or "crypto" or "auto"
    memo="Payment for API usage"
)

print(f"Payment ID: {payment['payment_id']}")
print(f"Status: {payment['status']}")
print(f"Client Secret: {payment['client_secret']}")

# Check payment status
status = client.get_payment(payment['payment_id'])
print(f"Current status: {status['status']}")

Payment Methods

Crypto Payments (ETH on Base)

# Add crypto wallet
method = client.add_payment_method(
    agent_id="agent_123",
    method_type="crypto_wallet",
    wallet_address="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    is_default=True
)

# Make crypto payment
payment = client.create_payment(
    to_agent_id="agent_456",
    amount=0.01,
    currency="ETH",
    payment_method="crypto"
)

Stripe Payments (Credit/Debit Cards)

# Add Stripe card (payment_method_id from Stripe.js frontend)
method = client.add_payment_method(
    agent_id="agent_123",
    method_type="stripe_card",
    stripe_payment_method_id="pm_1234567890",
    is_default=True
)

# Make card payment
payment = client.create_payment(
    to_agent_id="agent_456",
    amount=100.00,
    currency="USD",
    payment_method="stripe_card"
)

API Reference

AgentPaymentClient

__init__(api_key, base_url, timeout)

Initialize the client.

create_payment(to_agent_id, amount, currency, payment_method, memo)

Create a new payment.

get_payment(payment_id)

Get payment status.

health_check()

Check API health.

add_payment_method(agent_id, method_type, ...)

Add payment method.

list_payment_methods(agent_id)

List all payment methods.

delete_payment_method(method_id)

Remove payment method.

Error Handling

from agent_payment_sdk import PaymentError, NetworkError

try:
    payment = client.create_payment(
        to_agent_id="agent_456",
        amount=50.00
    )
except PaymentError as e:
    print(f"Payment failed: {e}")
except NetworkError as e:
    print(f"Network error: {e}")

Features

  • ✅ Hybrid crypto + fiat payments
  • ✅ Automatic payment method selection
  • ✅ Payment method management
  • ✅ Type hints for better IDE support
  • ✅ Comprehensive error handling
  • ✅ Simple, intuitive API

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

agent_payment_sdk-0.1.5.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

agent_payment_sdk-0.1.5-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file agent_payment_sdk-0.1.5.tar.gz.

File metadata

  • Download URL: agent_payment_sdk-0.1.5.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for agent_payment_sdk-0.1.5.tar.gz
Algorithm Hash digest
SHA256 5a01f05638549ccdc31b7bdf3ff76b085917d23e11c7eac4713d52ca4046b1fe
MD5 bb43f7dfca0efa8c50d2249fc126b1fb
BLAKE2b-256 90572319406565e7bf5f2c7ea35877b999c6ada3a992a689b91f83d66ce100c0

See more details on using hashes here.

File details

Details for the file agent_payment_sdk-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_payment_sdk-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d9f1ddaf39ba4aa66d5b8039a6d45dbdf0ef5728df7f088bd5bc90503cd36c6d
MD5 852d5bce73959ac5ae64ab96b6de65ba
BLAKE2b-256 ddadb9dbaf39b36633e5f2494281937691e6ac16c2375da84bece1964d23ac1b

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