Skip to content

Support Kernel wallet payment methods and payment_request items - #306

Draft
hiroTamada wants to merge 1 commit into
mainfrom
hypeship/kernel-wallet-payment-methods
Draft

hiroTamada wants to merge 1 commit into
mainfrom
hypeship/kernel-wallet-payment-methods

Conversation

@hiroTamada

Copy link
Copy Markdown
Contributor

Important

Blocked on the kernel-go-sdk v0.133.0 release. go.mod pins the unreleased release-PR head as a pseudo-version (v0.132.1-0.20261027142730-6b2ae5c1cb1d, commit 6b2ae5c on kernel/kernel-go-sdk#213). Before merging, bump to the published v0.133.0 (go get github.com/kernel/kernel-go-sdk@v0.133.0 && go mod tidy) and re-run the tests.

Summary

The API now supports multiple cards per Kernel wallet (add_payment_method / remove_payment_method) and payment_request items for Link and Kernel purchases. Both are enabled per organization. This PR adds both to the vault commands. Organizations without them keep the original single-card Kernel wallet contract: wallets create --provider kernel still shows the default card's card_enrollment action, and Kernel cards without payment_method_id send the same request as before.

Payment methods

  • items invoke <vault> <wallet> add_payment_method and the shortcut wallets add-payment-method <vault> <wallet> print the new method, its status, its card_enrollment URL and expiry, and the existing guidance to share it privately with the cardholder. --open is allowed for a cardholder on their own machine.
  • items invoke <vault> <wallet> remove_payment_method --params '{"payment_method_id":"<id>"}' (or --spec-file) and wallets remove-payment-method --payment-method-id <id>, which asks for confirmation unless --yes is passed, print the removal result. They also state that removal is not proof that a payment did not occur.
  • Operation results were previously rejected as "unexpected vault operation response"; they now go through their own display-safe projection.
  • Errors now come with specific guidance: 409 purchase_unresolved (reconcile the funded purchase first), 409 provider_revocation_pending (method stays removal_pending; retry later), 409 on add (10-method / 3-open-link limits), 403 insufficient_scope (needs vaults:write in addition to vaults:use), and 429 (honors Retry-After). When either operation is not advertised, the error explains when the API offers it.
  • wallets payment-methods adds a status column and prints status_reason and any pending enrollment URL with its expiry. The Kernel guidance now covers optional payment_method_id, the default card card, method statuses, and when to remove a method or contact support.

payment_request items

  • cards create|update --type payment_request sends type: payment_request through the SDK's PaymentRequest upsert/update params; --type defaults to card. AgentCard is rejected with --type payment_request, and Kernel updates stay blocked as for Kernel cards.
  • payment_request items are rendered like card items in items get/list and invoke results, including Link authorize --browser-id/--page-url and fill handling.
  • Kernel purchases show payment method id (bound method from state, falling back to spec) and funding status. They warn when funding_status is unavailable or removed.

Output projection

  • Payment methods: status, status_reason, expires_at, action.{name,url}. capture_token is never printed in either output mode.
  • Item state: payment_method_id, funding_status.
  • Event data: item_type, provider, payment_method_id_present (payment_method_id was already kept).

Help

  • The Kernel wallet spec, wallet-create text, KernelCardSpec (optional payment_method_id), the payment_request section, items invoke, and the root payment flow now describe empty wallets, add/remove, method statuses, funding_status and the vaults:write requirement.
  • reconnect_required guidance now matches the API: legacy wallets refuse payment and deletion until upgraded. The previous "share the new card_enrollment action" no longer applies.

Testing

  • make test (go vet ./... + go test ./...): passes.
  • golangci-lint run --new-from-rev=HEAD ./... (v2.15.0): 0 new issues. Existing repo-wide warnings are unchanged.
  • New and updated unit tests cover add/remove through both invoke and the wallet shortcuts, request bodies, JSON/human projection (including that capture_token is withheld), error guidance per code, the unadvertised-operation message, parameter validation, --open, payment_request create/update/authorize bodies, funding display, event projection, and help text.
  • Checked human output manually against a local fake API. Not tested against a live API with the flags enabled.

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.

1 participant