-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquickstart_merchant.py
More file actions
59 lines (46 loc) · 1.76 KB
/
quickstart_merchant.py
File metadata and controls
59 lines (46 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
AgentGatePay Python SDK - Merchant Quickstart Example
Time to integration: ~5 minutes
"""
import os
from agentgatepay_sdk import AgentGatePay
def main():
# Initialize client (API key required for merchant features)
client = AgentGatePay(
api_key=os.getenv("AGENTPAY_API_KEY"),
agent_id="my-merchant",
debug=True
)
print("=== AgentGatePay Merchant Quickstart ===\n")
# Step 1: Verify a payment
print("Step 1: Verifying payment...")
verification = client.payments.verify("0x1234567890abcdef...")
print("Payment verified!")
print(f" Valid: {verification.get('isValid')}")
print(f" Amount: ${verification.get('amountUsd')}")
print(f" From: {verification.get('sender')}")
print(f" Token: {verification.get('token')} on {verification.get('chain')}\n")
# Step 2: Configure webhook
print("Step 2: Configuring webhook...")
webhook = client.webhooks.create(
url="https://myserver.com/agentpay-webhook",
events=["payment.completed", "payment.failed"],
secret="my-webhook-secret-123"
)
print("Webhook configured!")
print(f" ID: {webhook['webhookId']}")
print(f" URL: {webhook['url']}")
print(f" Events: {', '.join(webhook['events'])}\n")
# Step 3: Get revenue analytics
print("Step 3: Getting revenue analytics...")
revenue = client.analytics.get_revenue(
start_date="2025-11-01",
end_date="2025-11-07"
)
print("Revenue analytics:")
print(f" Total revenue: ${revenue['totalRevenueUsd']}")
print(f" Transactions: {revenue['transactionCount']}")
print(f" Average: ${revenue['averageTransactionUsd']}\n")
print("✓ Complete! You can now accept payments from AI agents.\n")
if __name__ == "__main__":
main()