Skip to content

Commit 06f47c6

Browse files
committed
adding payman
1 parent bb50b4a commit 06f47c6

2 files changed

Lines changed: 196 additions & 0 deletions

File tree

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
import os
2+
from typing import Dict, List, Optional, Union, Literal
3+
from paymanai import Paymanai
4+
5+
# Initialize Payman client
6+
PAYMAN_API_SECRET = os.getenv("PAYMAN_API_SECRET")
7+
PAYMAN_ENVIRONMENT = os.getenv("PAYMAN_ENVIRONMENT")
8+
9+
client = Paymanai(
10+
x_payman_api_secret=PAYMAN_API_SECRET,
11+
environment=PAYMAN_ENVIRONMENT
12+
)
13+
14+
def send_payment(
15+
amount_decimal: float,
16+
payment_destination_id: Optional[str] = None,
17+
payment_destination: Optional[Dict] = None,
18+
customer_id: Optional[str] = None,
19+
customer_email: Optional[str] = None,
20+
customer_name: Optional[str] = None,
21+
memo: Optional[str] = None
22+
) -> Dict:
23+
"""
24+
Send a payment using Payman.
25+
26+
Args:
27+
amount_decimal: Amount to send in decimal format
28+
payment_destination_id: ID of existing payment destination
29+
payment_destination: Dictionary containing payment destination details
30+
customer_id: Optional customer ID
31+
customer_email: Optional customer email
32+
customer_name: Optional customer name
33+
memo: Optional payment memo
34+
35+
Returns:
36+
Dictionary containing payment details
37+
"""
38+
try:
39+
return client.payments.send_payment(
40+
amount_decimal=amount_decimal,
41+
payment_destination_id=payment_destination_id,
42+
payment_destination=payment_destination,
43+
customer_id=customer_id,
44+
customer_email=customer_email,
45+
customer_name=customer_name,
46+
memo=memo
47+
)
48+
except Exception as e:
49+
return {"error": f"Failed to send payment: {str(e)}"}
50+
51+
def search_available_payees(
52+
name: Optional[str] = None,
53+
contact_email: Optional[str] = None,
54+
type: Optional[str] = None
55+
) -> List[Dict]:
56+
"""
57+
Search for available payment destinations/payees.
58+
59+
Args:
60+
name: Optional name filter
61+
contact_email: Optional email filter
62+
type: Optional payment type filter
63+
64+
Returns:
65+
List of matching payment destinations
66+
"""
67+
try:
68+
return client.payments.search_payees(
69+
name=name,
70+
contact_email=contact_email,
71+
type=type
72+
)
73+
except Exception as e:
74+
return [{"error": f"Failed to search payees: {str(e)}"}]
75+
76+
def add_payee(
77+
type: Literal["CRYPTO_ADDRESS"] | Literal["US_ACH"],
78+
name: Optional[str] = None,
79+
contact_details: Optional[Dict] = None,
80+
account_holder_name: Optional[str] = None,
81+
account_number: Optional[str] = None,
82+
account_type: Optional[str] = None,
83+
routing_number: Optional[str] = None,
84+
address: Optional[str] = None,
85+
currency: Optional[str] = None,
86+
tags: Optional[List[str]] = None
87+
) -> Dict:
88+
"""
89+
Add a new payee/payment destination.
90+
91+
Args:
92+
type: Type of payment destination ("CRYPTO_ADDRESS" or "US_ACH")
93+
name: Optional name for the payment destination
94+
contact_details: Optional dictionary containing contact information
95+
account_holder_name: Required for US_ACH
96+
account_number: Required for US_ACH
97+
account_type: Required for US_ACH
98+
routing_number: Required for US_ACH
99+
address: Required for CRYPTO_ADDRESS
100+
currency: Optional currency specification
101+
tags: Optional list of tags
102+
103+
Returns:
104+
Dictionary containing the created payee details
105+
"""
106+
try:
107+
return client.payments.create_payee(
108+
type=type,
109+
name=name,
110+
contact_details=contact_details,
111+
account_holder_name=account_holder_name,
112+
account_number=account_number,
113+
account_type=account_type,
114+
routing_number=routing_number,
115+
address=address,
116+
currency=currency,
117+
tags=tags
118+
)
119+
except Exception as e:
120+
return {"error": f"Failed to add payee: {str(e)}"}
121+
122+
def ask_for_money(
123+
amount_decimal: float,
124+
customer_id: str,
125+
customer_email: Optional[str] = None,
126+
customer_name: Optional[str] = None,
127+
memo: Optional[str] = None
128+
) -> Dict:
129+
"""
130+
Generate a checkout link to request money from a customer.
131+
132+
Args:
133+
amount_decimal: Amount to request in decimal format
134+
customer_id: Customer's ID
135+
customer_email: Optional customer email
136+
customer_name: Optional customer name
137+
memo: Optional memo for the request
138+
139+
Returns:
140+
Dictionary containing the checkout URL
141+
"""
142+
try:
143+
response = client.payments.initiate_customer_deposit(
144+
amount_decimal=amount_decimal,
145+
customer_id=customer_id,
146+
customer_email=customer_email,
147+
customer_name=customer_name,
148+
memo=memo
149+
)
150+
return {"checkout_url": response.checkout_url}
151+
except Exception as e:
152+
return {"error": f"Failed to generate payment request: {str(e)}"}
153+
154+
def get_balance(
155+
customer_id: Optional[str] = None,
156+
currency: str = "USD"
157+
) -> Dict:
158+
"""
159+
Get balance information.
160+
161+
Args:
162+
customer_id: Optional customer ID (if None, returns agent balance)
163+
currency: Currency to check balance for
164+
165+
Returns:
166+
Dictionary containing balance information
167+
"""
168+
try:
169+
if customer_id and customer_id.lower() != "none":
170+
return client.balances.get_customer_balance(
171+
customer_id=customer_id, # Use keyword arguments
172+
currency=currency
173+
)
174+
return client.balances.get_spendable_balance(
175+
currency=currency
176+
)
177+
except Exception as e:
178+
return {"error": f"Failed to get balance: {str(e)}"}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "payman",
3+
"category": "financial-infra",
4+
"tools": [
5+
"send_payment",
6+
"search_available_payees",
7+
"add_payee",
8+
"ask_for_money",
9+
"get_balance"
10+
],
11+
"url": "https://www.paymanai.com",
12+
"cta": "Setup your Agents Payman account at https://app.paymanai.com",
13+
"env": {
14+
"PAYMAN_API_SECRET": null,
15+
"PAYMAN_ENVIRONMENT": null
16+
},
17+
"dependencies": ["paymanai>=2.1.0"]
18+
}

0 commit comments

Comments
 (0)