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.4.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.4-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_payment_sdk-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 da4fdecc8e59eed6a3420638384dcaee34cdf89458b6e3503019f77a221d8452
MD5 d96cfd7a55ff70181aad4db30fbd539c
BLAKE2b-256 7fff318b2b32687cbd86e783d4ae78ffb9fcd6ef123b9eef1bba48277cd5adfa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agent_payment_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1c87da3c7a1f281288b81e993b1d03037b442533113bec60bc6c7b0cfebccc69
MD5 3fc5d2dd6ae5d4a3f016c087c58233ac
BLAKE2b-256 36721671cedb0014883eae0272ffd85d56d7cf2f379e37550d4e78e36c2bec3e

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