Python SDK for AI Agent Payment Network - Hybrid crypto + fiat payments
Project description
agent-payment-sdk
Python SDK for AgentPayment Network — the only hybrid crypto + fiat payment infrastructure built for autonomous AI agent-to-agent transactions.
Installation
pip install agent-payment-sdk
Quick Start
from agent_payment_sdk import AgentPaymentClient
client = AgentPaymentClient(
api_key="your_api_key",
base_url="https://api.agentpayment.network"
)
# Send a payment
payment = client.send_payment(
from_agent_id="your_agent_id",
to_agent_id="receiver_agent_id",
amount=10.00,
payment_method="crypto" # "crypto", "stripe_card", or "ach"
)
print(payment)
Get your API key by signing up at agentpayment.network.
Payment Rails
Crypto (ETH on Base Mainnet)
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=5.00,
payment_method="crypto"
)
Stripe Card
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=25.00,
payment_method="stripe_card",
payment_method_id="pm_your_stripe_pm_id"
)
ACH Bank Transfer
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=100.00,
payment_method="ach",
payment_method_id="your_plaid_payment_method_id"
)
Agent-to-Agent Billing
Provider agents can autonomously invoice consumer agents. Consumer agents can set auto-approval rules so payments execute instantly with no human required.
Create an Invoice (Provider Agent)
invoice = client.create_invoice(
from_agent_id="provider_agent",
to_agent_id="consumer_agent",
amount=15.00,
currency="USD",
payment_rail="crypto",
description="API usage fee - 1000 requests"
)
print(f"Invoice ID: {invoice['invoice_id']}")
print(f"Status: {invoice['status']}")
Set Auto-Approval Rule (Consumer Agent)
rule = client.set_billing_rule(
agent_id="consumer_agent",
approved_provider_id="provider_agent",
max_amount=50.00,
payment_rail="crypto"
)
# Now any invoice from provider_agent under $50 will auto-pay instantly
Pay an Invoice Manually
result = client.approve_invoice(
invoice_id="invoice_uuid",
agent_id="consumer_agent"
)
print(f"Paid: {result['status']}")
List Invoices
invoices = client.list_invoices(agent_id="your_agent_id")
for inv in invoices:
print(f"{inv['invoice_id']} — ${inv['amount']} — {inv['status']}")
Webhooks
Subscribe to payment events so your agent gets notified instantly.
# Register a webhook endpoint
webhook = client.create_webhook(
url="https://your-agent.com/webhooks",
events=["payment.completed", "payment.failed", "invoice.paid"]
)
print(f"Webhook secret: {webhook['secret']}")
Verify incoming webhooks with HMAC-SHA256:
import hmac, hashlib
def verify_webhook(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), payload, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
Error Handling
from agent_payment_sdk import PaymentError, NetworkError
try:
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=10.00,
payment_method="crypto"
)
except PaymentError as e:
print(f"Payment failed: {e}")
except NetworkError as e:
print(f"Network error: {e}")
Resources
- Docs: agentpayment.network/docs
- Live Demo: agentpayment.network/demo
- PyPI: pypi.org/project/agent-payment-sdk
- Support: support@agentpayment.network
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 agent_payment_sdk-0.3.2-py3-none-any.whl.
File metadata
- Download URL: agent_payment_sdk-0.3.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e777b02721fe8f47ffeef1919d853659cdbc26b28f9cf69c9641de035a0f0fdc
|
|
| MD5 |
3e76ffd342b8f34683412b2ea8dc7f73
|
|
| BLAKE2b-256 |
68e30245b7a6c68a2561b0ea01410487caadd283a68cdf37d5d119982476ef93
|