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:8002"
)

# 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.3.tar.gz (9.3 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.3-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_payment_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 9.3 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.3.tar.gz
Algorithm Hash digest
SHA256 88cfe3af9cb767293bb4a776e4cbd961ec6c9a6560d3ecbe172de00d7235d614
MD5 3a587bfce2ada9d870797f9c275e4710
BLAKE2b-256 379611621b708a3a968cea2748d59a0d4035b6c1224a0a753e9d65d709aab34e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agent_payment_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7967417582ffa6855fecf538822d13e87896535f184e13d3ce91570605d78d70
MD5 7ce2735146001c752fcecaad9a3d7f09
BLAKE2b-256 bf2433d2fe91af7acb68982981d2c693b691a708b54e06b6b036d96cdf29e7ba

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