feat(agent-commerce): ACP/UCP エージェント決済ハンドラと Gateway 抽象を追加#54
Draft
nanasess wants to merge 1 commit into
Draft
Conversation
本体のエージェントチェックアウト (#6776 ACP / #6574 UCP) の決済ハンドラ seam に対する サンプル実装。通常購入のトークン決済 (CreditCard) を流用し、Stripe/ChatGPT 非依存で 結合 E2E を緑化する。stripe-payment-plugin への移植リファレンスを兼ねる。 - Gateway 抽象 (PSP 隔離): AgentPaymentGatewayInterface + GatewayResult/GatewayStatus (Stripe PaymentIntent.status 語彙に整合) + MockAgentPaymentGateway (トークン規約で 成功/3DS/拒否/不正/処理中 を決定的に分岐)。 - AbstractAgentCardHandler: supports() = methodClass + Order.agentProtocol 一致、 Order 総額→minor unit→gateway、GatewayResult→PaymentOutcome 写像。 - AcpSampleCardHandler (handler_id=card_tokenized, redeemSharedPaymentToken) / UcpSampleCardHandler (handler_id=dev.ucp.payment.card, exchangePaymentToken)。 - services.yaml は gateway interface→Mock の alias のみ (具象とタグは本体 glob/_instanceof が自動付与)。 PluginManager は sort_no 操作なし。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
EC-CUBE 本体のエージェントコマース対応(ACP / UCP)に対する、サンプル決済での決済ハンドラ参考実装です。本体が定義する決済ハンドラ interface の具象を本プラグイン側に実装し、AI エージェント経由の購入(authorize / capture / トークン償還・交換、3DS 中断・再開)を sample 決済で完結させます。
Important
このPRは本体側 PR の依存先がマージされるまでドラフトです。 本体に以下の型が入るまで autoload / CI は通りません(意図的)。
Eccube\Service\AgentCommerce\Payment\AgentCheckoutPaymentHandlerInterface/PaymentOutcome(共通基盤 #6777)Eccube\Service\AgentCommerce\Payment\AcpPaymentHandlerInterface(ACP #6776)Eccube\Service\AgentCommerce\Payment\UcpPaymentHandlerInterface(UCP #6574)本体側マージ後に CI を再実行し、ドラフトを解除します。
実装内容(
Service/AgentCommerce/)Gateway 抽象(PSP 境界の分離)
Gateway/GatewayStatus.php—succeeded/requires_capture/requires_action/processing/failedの enum。決済ゲートウェイの状態語彙を中立化(PSP の状態にそのまま写像できる形)。Gateway/GatewayResult.php— 結果 DTO(readonly・ファクトリ付き)。Gateway/AgentPaymentGatewayInterface.php—authorize()/capture()(通貨・最小単位整数額・instrument・context)。Gateway/MockAgentPaymentGateway.php— トークン規約でシナリオを再現するモックゲートウェイ:*-3ds*→ 追加認証(requires_action、再開時authentication_result同伴で成功)*-decline*→ 与信拒否(failed・再試行可) /*-fraud*→ 不正検知(failed・再試行不可)*-processing*→ 非同期処理中(processing) / それ以外 → 与信成功(requires_capture)→ capture でsucceededpi_mock_<sha256>)。ハンドラ
AbstractAgentCardHandler.php— 共通基底。supports()は支払方法が CreditCard かつOrder.getAgentProtocol()がプロトコル一致のときのみ true。GatewayResult→ 本体PaymentOutcomeへマッピング(succeeded/requires_capture→completed、requires_action→requiresAction、processing→pending、failed→failed)。Acp/AcpSampleCardHandler.php—AcpPaymentHandlerInterface実装。handler_id = card_tokenized、redeemSharedPaymentToken()(ACP Shared Payment Token の償還)。Ucp/UcpSampleCardHandler.php—UcpPaymentHandlerInterface実装。handler_id = dev.ucp.payment.card、exchangePaymentToken()(UCP のトークン交換)。具象ハンドラは
agent_commerce.payment_handlerタグ(本体の_instanceof自動付与)で登録され、本体のレジストリが checkout 解決・discovery 広告に利用します。検証
本体↔本プラグイン↔eccube-api4 の結合 E2E(本体側
agentic-commerce-e2eワークフロー、run_payment=true)で、ACP / UCP の 成功 / 3DS 中断・再開 / 拒否 の全シナリオが通ることを確認済みです。補足