Skip to content

@agentaos/pay 2.0: new API surface, management + subscriptions, pagination, void() fix - #32

Open
PancheI wants to merge 11 commits into
mainfrom
feat/pay-seller-mode-subscriptions
Open

@agentaos/pay 2.0: new API surface, management + subscriptions, pagination, void() fix#32
PancheI wants to merge 11 commits into
mainfrom
feat/pay-seller-mode-subscriptions

Conversation

@PancheI

@PancheI PancheI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

@agentaos/pay 2.0 — the new-API-era release.

  • Server-owned seller mode; subscriptions + dueDate; new API surface.
  • 2.0.0 major release.
  • Real SDK test suite (was zero); tests excluded from the published npm tarball.
  • Management surface: subscriptions/customers list + cancel, receipt methods.
  • Mirrored into the MCP tools + CLI + docs.
  • subscriptions.list + customers.list paginated to match the sibling resources ({ items, total, hasMore }).
  • Fix: invoices.void() now POST /gateway/invoices/{id}/void (was DELETE /{id}, which 404s), with its test corrected.

Pre-push test suite green.

🤖 Generated with Claude Code

PancheI and others added 11 commits August 5, 2026 20:38
…surface

Seller mode is derived by the server from the account — never a client input.
Remove sellerMode from the create params (CreatePaymentLinkParams,
CreateCheckoutParams); the resolved value is still returned on responses
(PaymentLink, Checkout) for display.

Add the additive new API surface: subscription payment links (type,
billingInterval), invoice dueDate on checkouts, and the response fields
sellerMode/type/billingInterval (PaymentLink) + sellerMode/invoiceId/
invoiceNumber (Checkout). Changeset: minor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The SDK shipped untested. Add 91 behavioral tests across the untested core:
- fetch.ts: header/auth selection, idempotency key, body-sent-as-is + response
  camelization, retries (429/5xx/network → success and exhaustion), and the full
  status->error-class mapping (400 ValidationError w/ errors[], 401/403/404/409,
  429 RateLimitError, 5xx ApiError, AbortError->TimeoutError).
- client.ts: sk_ vs JWT auth detection, invalid-key + browser guards, baseUrl,
  resource wiring.
- transform.ts: snake<->camel (nested/arrays/Date/round-trip).
- resources: every checkouts/paymentLinks/transactions/invoices method asserted
  against captured METHOD+PATH + camelized returns.
- webhooks.verify: REAL node:crypto HMAC + timingSafeEqual (valid/tampered/expired).
Only the fetch boundary is mocked. Also drop a dead camelToSnake import in fetch.ts.

typecheck 0 · 96 tests green · lint clean · build ok.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
….js to npm)

Every published package compiled its src/**/*.test.ts into dist/, so the npm
tarball shipped the test files to consumers. Add a per-package tsconfig.build.json
(extends tsconfig.json + excludes *.test.ts/*.spec.ts) and point `build` at it, so
dist ships only production code. `typecheck` still uses tsconfig.json and keeps
type-checking the tests. Applied to the 5 packages that had tests: pay, chains,
schemes (@agentaos/engine), signer (@agentaos/sdk), wallet (agentaos CLI).

Verified: each rebuilds with 0 test.js in dist; typecheck still covers tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mirror the dashboard's merchant management/read API in the SDK, matching the
professional MoR-SDK bar (resource.operation, like Creem/Polar/Paddle). Read +
manage only — subscriptions are created by buyers on the hosted checkout, never
by the SDK.

- subscriptions.list() / subscriptions.cancel(id, { atPeriodEnd }) — defaults to
  cancel-at-period-end (subscriber keeps the paid period, no refund).
- customers.list().
- invoices.getReceipt(id) (receipt PDF) / invoices.sendReceipt(id).
- Types typed against the live BE contracts (list endpoints return plain arrays,
  not paginated envelopes; camelCase keys verified).
- CLI parity: agenta subscriptions list|cancel, agenta customers list.
- Tests (102 pay green) + README + folded into the 2.0.0 changeset.
- Independently reviewed (spec + quality), lint-green, live local smoke 7/7.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…docs

Bring the CLI and MCP server to parity with @agentaos/pay's management surface.

MCP (4 new agenta_pay_* tools): list_subscriptions, cancel_subscription,
list_customers, send_receipt. (No get_receipt tool — a binary PDF isn't useful
over MCP text; it stays CLI/SDK.)

CLI: new 'agenta invoices' group — list, receipt <id> (downloads the PDF),
send-receipt <id>. Rounds out subscriptions/customers (already shipped).

Docs: wallet + top-level README CLI tables + MCP tool list; corrected the tool
count to the real total (25) — the wallet README had also silently omitted the
pre-existing pay tools, now backfilled. Changeset for agentaos (minor).

typecheck + lint + build + mcp-server test green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…g resources)

The BE now paginates these two endpoints, so bring the SDK in line with every
other list resource: list(params?: ListParams) -> PaginatedList<T> ({items,
total, hasMore}) instead of a bare array. CLI gains --limit + a '(N total)'
header and 'X of Y shown' note; MCP tools accept limit/offset. README updated.

Tests: 102 pay tests green; CLI/MCP typecheck + build clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
void() called DELETE /gateway/invoices/{id}, which is not a route (404). The
real endpoint is POST /gateway/invoices/{id}/void. Corrects the method and the
test that was asserting the wrong DELETE behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ntaos/pay, core libs)

Applied the queued changesets: agentaos (CLI) major -> 2.0.0, cascading the fixed
group (@agentaos/core, /crypto, /engine, /chains, /sdk) to 2.0.0; @agentaos/pay
major -> 2.0.0. CLI now ships the MoR management surface (subscriptions, customers,
invoices) at 2.0.0, matching the SDK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
x402-client.test.ts hit httpbin.org live (flaky: 15s timeouts, a different assert
failing each run). Renamed it to *.integration.test.ts and excluded integration
tests from 'test' (matching @agentaos/engine); added 'test:integration' to run
them on demand. Gate now runs only deterministic unit tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reverses the earlier exclusion. x402-client is a UNIT test that lazily hit
httpbin.org live (flaky: 15s timeouts, a different assert failing each run). Renamed
it back from *.integration and mocked the global fetch so checkX402/discoverX402 are
deterministic (added JSON-402 + .well-known manifest coverage). Restored the wallet
'test' script to run everything (no --exclude). x402-live.integration.test.ts (a
genuine live test vs a real x402 server) stays in the gate as before. Suite green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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