Inspiration

Creating a payment normally means filling forms or calling APIs by hand. We wanted to see how simple payments could become if a user could just type what they want, such as "create payment 10 USD", and have an agent handle the PayPal steps safely.

What it does

PayPal AI Agent is a Java command-line app connected to the PayPal Sandbox.

  • The user asks for a payment in plain language (for example, "create payment 10 USD").
  • The agent reads the amount, asks the user to confirm, and creates an order through the PayPal Orders API.
  • It returns the Order ID and an approval link.
  • The buyer opens the link, logs in with a Sandbox buyer account, and approves the payment.
  • The user types "capture " and the agent captures the payment (status: COMPLETED).
  • Any other message is answered by Gemini as a normal chat assistant.

How we built it

  • Java 17 and Maven.
  • PayPal Checkout SDK for the Orders API (create order, capture order) in the PayPal Sandbox.
  • Gemini through LangChain4j for the conversational part.
  • Payment commands are handled directly by our code. Gemini does not call the payment functions itself, so a model mistake cannot trigger a payment.

Safety by design

  • Sandbox only, so no real money is used.
  • Every order needs an explicit "yes" from the user before it is created.
  • Amounts are limited to 0-1000 USD.
  • API keys are read from environment variables and are never stored in the repository.

Challenges we ran into

We first let Gemini call the PayPal functions as tools, but the newer Gemini model rejected our tool-call round trip because of a missing thought signature. We solved this by moving the payment logic into plain code with a confirmation step, and keeping Gemini for chat. This also made the agent safer and more predictable.

Accomplishments we are proud of

A complete working flow: create order, buyer approval in the Sandbox, and successful capture with status COMPLETED, with a clear confirmation step in between.

What we learned

How the PayPal Orders API lifecycle works (create, approve, capture), and why payment actions should stay under explicit user confirmation when AI is involved.

What's next

Refunds, an order status check, a web interface, and letting the AI understand more natural requests while keeping the confirmation step.

Built With

Share this project:

Updates

Submission history