メインコンテンツへスキップ
見出し画像

Agent Payments Protocol (AP2) のサンプルを試す

    「Agent Payments Protocol」(AP2) のサンプルを試したのでまとめました。

    前回

    1. Agent Payments Protocol (AP2)

    「Agent Payments Protocol」(AP2) は、エージェント同士が安全に買い物や支払いを行うための仕組みで、ユーザーの意図・カート内容・支払いをそれぞれ署名付きで承認し合うことで、透明で信頼できる自動決済を可能にするプロトコルです。

    2. Agent Payments Protocol (AP2) のサンプルを試す

    「Agent Payments Protocol」(AP2) のサンプルを試す手順は、次のとおりです。

    (1) 環境変数に「Google APIキー」を指定。

    export GOOGLE_API_KEY=<Google APIキー>

    (2) リポジトリのクローン。

    git clone https://github.com/google-agentic-commerce/AP2
    cd AP2

    (3) サンプルの実行。

    samples/python/scenarios/a2a/human-present/cards/run.sh

    (4) ブラウザで「http://0.0.0.0:8000」を開く。

    画像

    (5) エージェント種別で「shopping_agent」を選択。

    ・shopping_agent : ショッピングエージェントの起動
    ・merchant_agent : マーチャントエージェントの起動
    ・merchant_payment_processor_agent : マーチャント決済処理エージェントの起動
    ・credentials_provider_agent : 認証情報プロバイダーの起動

    (6) リクエスト開始。
    購入意図を入力します。

    user: I want to buy a coffee machine
    shopper: Could you please provide a more detailed description of the coffee machine you are looking for? For example, what type of coffee machine (e.g., drip, espresso, single-serve), what features are important to you, or any specific brands?

    【翻訳】
    user: コーヒーメーカーを購入したい
    shopper: お探しのコーヒーマシンについて、もう少し詳しくご説明いただけますか?例えば、コーヒーマシンの種類(ドリップ、エスプレッソ、シングルサーブなど)、重視する機能、具体的なブランドなどについて教えてください。

    画像

    (7) 商品検索。

    user: I want to buy the cheapest coffee machine possible.
    shopper: Understood. Do you have a preference for whether the item needs to be refundable?
    user: No
    shopper: Please confirm the following details for your purchase. Note that this information will be shared with the merchant.Item Description: cheapest coffee machine User Confirmation Required: Yes Merchants: Any SKUs: Any Refundable: No Expires: in 1 dayShall I proceed?
    user: Yes
    shopper: I've found a few options for you.

    1. Manual French Press Coffee Maker
    Price: $19.99
    Expires: in 1 day
    Refund Period: 14 days
    This option is the cheapest available and fulfills your request for the most affordable coffee machine.

    2. Basic Drip Coffee Maker
    Price: $24.99
    Expires: in 1 day
    Refund Period: 30 days

    3. Compact Single Serve Coffee Maker
    Price: $29.99
    Expires: in 1 day
    Refund Period: 30 days

    Sold by: Generic Merchant
    Which item would you like to purchase?
    user: 1
    shopper: Great! Your selection has been updated. I'll now hand you over to the next step in the process.


    【翻訳】
    user: できるだけ安いコーヒーマシンを買いたい
    shopper: 了解しました。商品の返金が必要かどうか、ご希望はありますか?
    user: いいえ
    shopper: ご購入にあたり、以下の詳細をご確認ください。この情報は販売店と共有されますのでご注意ください。

    商品名:最安価格のコーヒーマシン
    ユーザー確認の要否:はい
    販売店:すべて
    SKU:すべて
    返金可能:いいえ
    有効期限:1日後

    続行しますか?
    user: はい
    shopper: いくつかの選択肢をご用意しました。

    1. 手動フレンチプレスコーヒーメーカー
    価格: 19.99ドル
    有効期限: 1日後
    返金期間: 14日間
    このオプションは、現在入手可能な中で最も安価で、最もお手頃なコーヒーマシンをお探しのお客様のご要望にお応えします。

    2. ベーシックドリップコーヒーメーカー
    価格: 24.99ドル
    有効期限: 1日後
    返金期間: 30日間

    3. コンパクトシングルサーブコーヒーメーカー
    価格: 29.99ドル
    有効期限: 1日後
    返金期間: 30日間

    販売元: Generic Merchant

    どの商品をご購入されますか?
    user: 1
    shopper: 素晴らしい!選択内容が更新されました。次のステップに進みましょう。

    画像

    (8) 商品購入。

    shipping_address_collector: Would you prefer to use a digital wallet to access your credentials for this purchase, or would you like to enter your shipping address manually?
    user: Google Wallet
    shipping_address_collector: This is where you might have to go through a redirect to prove your identity and allow your credentials provider to share credentials with the AI Agent. But this is a demo, so I will assume you have granted me access to your account, with the login of bugsbunny@gmail.com.

    Is that ok?
    user: Yes
    root_agent: Shipping Address:
    Bugs Bunny
    123 Main St
    Sample City, ST 00000
    US
    Phone: +1-000-000-0000
    Organization: Sample Organization
    payment_method_collector: Here is a summary of your order:

    Order Summary:
    Merchant: Generic Merchant
    Item: Manual French Press Coffee Maker
    Price Breakdown:
    Shipping: $2.00
    Tax: $1.50
    Total: $23.49
    Expires: September 28, 2025 at 07:16 AM UTC
    Refund Period: 14 days

    Shipping Address:
    Bugs Bunny
    123 Main St
    Sample City, ST 00000
    US
    Phone: +1-000-000-0000
    Organization: Sample Organization
    payment_method_collector: Here are your available payment methods:

    American Express ending in 4444
    American Express ending in 8888
    Which of these would you like to use for your payment? Please reply with the full description, for example, "American Express ending in 4444".
    user: American Express ending in 4444
    root_agent: Cart Contents: Item: Manual French Press Coffee Maker Price: $19.99 Shipping: $2.00 Tax: $1.50 Total Price: $23.49 Cart valid for: 1 day Refundable for: 14 days

    Shipping Address: Bugs Bunny 123 Main St Sample City, ST 00000 US Phone: +1-000-000-0000 Organization: Sample Organization

    Payment Method: American Express ending in 4444

    Do you confirm your purchase of the Manual French Press Coffee Maker for $23.49 using American Express ending in 4444?
    user: Yes
    root_agent: The payment method issuer sent a verification code to the phone number on file, please enter it below. It will be shared with the issuer so they can authorize the transaction.(Demo only hint: the code is 123)
    user: 123
    root_agent: Payment Receipt: Price: $19.99 Shipping: $2.00 Tax: $1.50 Total Price: $23.49

    Shipping Address: Bugs Bunny 123 Main St Sample City, ST 00000 US Phone: +1-000-000-0000 Organization: Sample Organization

    Payment Method: American Express ending in 4444

    【翻訳】
    shipping_address_collector: この購入の認証情報にアクセスするためにデジタル ウォレットを使用しますか、それとも配送先住所を手動で入力しますか?
    user: Googleウォレット
    shipping_address_collector: ここで、本人確認と認証情報プロバイダーによるAIエージェントとの認証情報共有を許可するために、リダイレクトを経由する必要があるかもしれません。ただし、これはデモなので、bugsbunny@gmail.com のログイン情報を使用して、アカウントへのアクセスを許可していただいたものとみなします。
    よろしいでしょうか?
    user: はい
    root_agent: 配送先住所:
    バッグス・バニー
    123 Main St
    Sample City, ST 00000
    米国
    電話番号:+1-000-000-0000
    組織:Sample Organization
    payment_method_collector: ご注文の概要は次のとおりです。

    注文概要:販売元:Generic Merchant 商品:手動フレンチプレスコーヒーメーカー 価格内訳:送料:2.00ドル 税金:1.50ドル 合計:23.49ドル 有効期限:2025年9月28日午前7時16分(UTC) 返金期間:14日間

    配送先住所:Bugs Bunny 123 Main St, Sample City, ST 00000US 電話番号:+1-000-000-0000 組織:Sample Organization
    payment_method_collector: ご利用可能なお支払い方法は以下の通りです。

    American Express ending in 4444
    American Express ending in 8888
    お支払いにどの方法をご利用になりますか? 詳細な説明(例:American Express ending in 4444)を添えてご返信ください。
    user: American Express ending in 4444
    root_agent: カートの内容:
    商品:手動フレンチプレスコーヒーメーカー
    価格:19.99ドル
    送料:2.00ドル
    税金:1.50ドル
    合計金額:23.49ドル
    カートの有効期限:1日間
    返金可能期間:14日間

    配送先住所:
    Bugs Bunny
    123 Main St
    Sample City, ST 00000
    US
    電話番号:+1-000-000-0000
    組織:Sample Organization

    お支払い方法:
    末尾が4444のAmerican Express

    23.49ドルの手動フレンチプレスコーヒーメーカーを、末尾が4444のAmerican Expressでご購入いただいたことをご確認いただけますか?
    user: はい
    root_agent: 
    お支払い方法の発行会社から、ご登録の電話番号に確認コードを送信しました。下記に入力してください。このコードは発行会社と共有され、取引の承認に使用されます。(デモ用ヒント: コードは123です)
    user: 123
    root_agent: 領収書:
    価格:19.99ドル
    送料:2.00ドル
    税金:1.50ドル
    合計金額:23.49ドル

    配送先住所:
    バッグス・バニー
    123 Main St
    Sample City, ST 00000
    米国
    電話番号:+1-000-000-0000
    組織:Sample Organization

    お支払い方法:
    American Express ending in 4444

    画像
    画像

    参考



     
     

    npaka

     
     
    プログラマー。iPhone / Android / Unity / ROS / AI / AR / VR / RasPi / ロボット / ガジェット。年2冊ペースで技術書を執筆。アニソン / カラオケ / ギター / 猫 twitter : @npaka123

    あなたへのおすすめ