Integrations
Set up your environment
Set up an integration
1
2
from paypal_agent_toolkit.openai.toolkit import PayPalToolkit
from paypal_agent_toolkit.common.configuration import Configuration, Context
configuration = Configuration(
actions={
"orders": {
"create": True,
"get": True,
"capture": True,
}
},
context=Context(
sandbox=True
)
)
# Initialize toolkit
toolkit = PayPalToolkit(client_id=PAYPAL_CLIENT_ID, secret=PAYPAL_SECRET, configuration = configuration)3
from agents import Agent
tools = toolkit.get_tools()
agent = Agent(
name="PayPal Assistant",
instructions="""
You're a helpful assistant specialized in managing PayPal transactions:
- To create orders, invoke create_order.
- After approval by user, invoke capture_order.
- To check an order status, invoke get_order_status.
""",
tools=tools
)4
1
2
import { PayPalAgentToolkit } from '@paypal/agent-toolkit/ai-sdk';
const paypalToolkit = new PayPalAgentToolkit({
clientId: process.env.PAYPAL_CLIENT_ID,
clientSecret: process.env.PAYPAL_CLIENT_SECRET,
configuration: {
actions: {
invoices: {
create: true,
list: true,
send: true,
sendReminder: true,
cancel: true,
generateQRC: true,
},
products: { create: true, list: true, update: true },
subscriptionPlans: { create: true, list: true, show: true },
shipment: { create: true, show: true, cancel: true },
orders: { create: true, get: true },
disputes: { list: true, get: true },
},
},
}); 3
const llm: LanguageModelV1 = getModel(); // The model to be used with ai-sdk
const { text: response } = await generateText({
model: llm,
tools: {
...paypalToolkit.getTools(),
// Extend with other tools
},
maxSteps: 10,
prompt: `Create an order for $50 for custom handcrafted item and get the payment link.`,
}); 4
1
2
3
{
"mcpServers": {
"paypal": {
"command": "npx",
"args": [
"-y",
"@paypal/mcp",
"--tools=all"
],
"env": {
"PAYPAL_ACCESS_TOKEN": "YOUR_PAYPAL_ACCESS_TOKEN",
"PAYPAL_ENVIRONMENT": "SANDBOX"
}
}
}
}1
2
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI
from paypal_agent_toolkit.langchain.toolkit import PayPalToolkit
# Initialize Langchain Toolkit
toolkit = PayPalToolkit(client_id=PAYPAL_CLIENT_ID, secret=PAYPAL_SECRET, configuration = configuration)
tools = toolkit.get_tools()
# Setup LangChain Agent
agent = initialize_agent(
tools=tools,
llm=llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True
)
prompt = "Create an PayPal order for $50 for Premium News service."
# Run the agent with the defined prompt
result = agent.run(prompt)3
1
2
from crewai import Agent, Crew, Task
from paypal_agent_toolkit.crewai.toolkit import PayPalToolkit
# Setup PayPal CrewAI Toolkit
toolkit = PayPalToolkit(client_id=PAYPAL_CLIENT_ID, secret=PAYPAL_SECRET, configuration = configuration)
tools = toolkit.get_tools()
# Define an agent specialized in PayPal transactions
agent = Agent(
role="PayPal Assistant",
goal="Help users create and manage PayPal transactions",
backstory="You are a finance assistant skilled in PayPal operations.",
tools=toolkit.get_tools(),
allow_delegation=False
)
# Define a CrewAI Task to create a PayPal order
task = Task(
description="Create an PayPal order for $50 for Premium News service.",
expected_output="A PayPal order ID",
agent=agent
)
# Assemble Crew with defined agent and task
crew = Crew(agents=[agent], tasks=[task], verbose=True,
planning=True,)3
Was this helpful?

