Skip to content

Conversation

@jorellis
Copy link
Contributor

@jorellis jorellis commented Dec 9, 2025

This PR introduces support for the x402 payment method within the Python human-in-the-loop agent scenarios. It enables the simulation of x402-compatible transactions across the Merchant, Shopping, and Payment Processor agents.

Key Changes:

  • Documentation: Added a detailed README.md for the x402 scenario, including setup and execution instructions.

  • Scripting: Updated run.sh to accept a --payment-method argument (defaulting to CARD).

  • Merchant Agent:

    • Updated catalog_agent.py to generate CartMandate artifacts with x402 specific PaymentMethodData when enabled.
    • Updated tools.py to route x402 payments to the correct processor.
  • Payment Processor Agent:

    • Enhanced tools.py to handle PAYMENT_METHOD environment variable.
    • Implemented logic to process x402 payment mandates, skipping the OTP challenge and credential provider lookup where appropriate (using mock/dummy clients).
    • Added logic to generate x402-specific payment receipts.
  • Shopping Agent:

    • Updated tools.py to co nstruct PaymentMandates with the correct method_name and details for x402.
    • Updated payment_method_collector/tools.py to mock x402 payment payloads when the payment method is set to x402.
  • Credentials Provider Agent:

    • Added a mock "x402_wallet" to the account_manager.py.
    • Updated tools.py to recognize https://www.x402.org/ as a supported method.

@jorellis jorellis requested a review from a team as a code owner December 9, 2025 05:23
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jorellis, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the agent-based simulation environment by introducing comprehensive support for the x402 payment method. It allows for end-to-end testing of x402-compatible transactions within the human-in-the-loop agent scenarios, ensuring that all relevant agents correctly process and interact with this new payment type. The changes include updates to core logic for payment processing, credential handling, and user interaction flows, alongside improved documentation for ease of use.

Highlights

  • x402 Payment Method Integration: Full support for the x402 payment method has been added across the Merchant, Shopping, and Payment Processor agents, enabling simulation of x402-compatible transactions.
  • Configurable Payment Method: The run.sh script now accepts a --payment-method argument, allowing users to easily switch between CARD (default) and x402 payment scenarios.
  • Updated Documentation: A comprehensive README.md has been added for the x402 scenario, detailing setup, execution, and interaction steps.
  • Mocking for x402: For x402 payments, the system now uses mock clients and skips certain steps like OTP challenges and direct credential provider lookups, streamlining the simulation.
  • Agent-Specific Logic: Each agent (Merchant, Shopping, Payment Processor, Credentials Provider) has been updated to correctly handle x402-specific data structures, routing, and processing flows.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@jorellis jorellis changed the title Feat/agent updates feat: Add X402 payment method support to Python human-in-the-loop samples Dec 9, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully introduces support for the x402 payment method across various agents in the human-in-the-loop scenario. The changes are well-contained and primarily involve conditional logic based on the selected payment method, which is appropriate for extending functionality.

My review focuses on improving robustness, consistency, and maintainability. I've identified a few areas for improvement:

  • The shell script for argument parsing could be more robust against missing arguments.
  • There's a potential logic issue in payment method eligibility checks that could be tightened.
  • I've noticed a discrepancy between the documentation and the implementation regarding the OTP challenge flow for x402.
  • There are opportunities to improve code consistency by passing parameters instead of reading environment variables in functions.
  • Finally, I've suggested replacing magic strings with constants to enhance maintainability.

Overall, these are solid changes that accomplish the goal of the PR. The suggested refinements aim to make the code more robust and easier to maintain.

Jordan Ellis and others added 4 commits December 15, 2025 22:08
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…s.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jorellis jorellis enabled auto-merge (squash) December 15, 2025 22:19
@jorellis jorellis merged commit 7f953cf into google-agentic-commerce:main Dec 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants