Files
suaveplan/openspec/archive/2026-05-17-add-payment-provider-paypal/tasks.md
2026-05-27 23:29:53 +01:00

59 lines
4.5 KiB
Markdown

# Tasks — add-payment-provider-paypal
> Every checkbox MUST reflect work actually done in this change. No retroactive ticking.
## 1. Spec authoring
- [x] 1.1 Read `../suaveplan/enterprise/payment-providers.md` end-to-end
- [x] 1.2 Read the slim-core spec and code (`packages/universal/payment-providers/src/`) plus the slim archive (`openspec/archive/2026-05-17-slim-payment-providers/`)
- [x] 1.3 Read `openspec/AGENTS.md` Sections 13 and 14 (and §7 test-runner rule)
- [x] 1.4 Draft `proposal.md` from `openspec/templates/proposal.md`
- [x] 1.5 Fill `## Source mapping` table — every requirement cites a line range OR appears in the "no source line" table with justification
- [x] 1.6 Draft `specs/payment-provider-paypal/spec.md` from `openspec/templates/spec-delta.md`
- [x] 1.7 Every requirement carries a `**Verified by:**` line naming concrete `it(...)` titles
## 2. Implementation
- [x] 2.1 Scaffold `packages/universal/payment-provider-paypal/` (package.json, tsconfig.json, tsconfig.lib.json, vite.config.ts, vitest.config.ts, README.md, tests/setup/polyfills.ts, tests/dep-graph.test.ts)
- [x] 2.2 Implement `src/paypal/paypal.types.ts` — `PayPalConfig` (extends `OAuthConfig` + `sandbox?: boolean`), `PayPalOrder`, `PayPalRefund`, `PayPalTokenResponse` wire shapes
- [x] 2.3 Implement `src/paypal/paypal.ts` — `PayPalProvider` class with constructor, token cache, all 6 `PaymentProvider` methods, status mapping helpers, amount marshalling, idempotency-header wiring
- [x] 2.4 Wire `src/paypal/index.ts` (named exports) and `src/index.ts` package barrel (named exports)
- [x] 2.5 Add subpath exports in `package.json` (`.`, `./paypal/paypal`, `./package.json`)
## 3. Tests
- [x] 3.1 `src/paypal/paypal.test.ts` — every scenario in the spec delta exercised via a `FetchLike` recorder closure (no `globalThis.fetch` patching); `FakeClock` for token-expiry assertions; all `it(...)` carry `{ timeout: 5000 }`
- [x] 3.2 `tests/dep-graph.test.ts` — pins dependency invariants (only `payment`, `payment-providers`, `error`, `tslib`; no Node/browser/React imports)
- [x] 3.3 Every test file imports runner primitives from `@suaveplan/testing/runner` (§7 / CLAUDE.md rule 11)
- [x] 3.4 Coverage at 100/100/100/100
## 4. Documentation
- [x] 4.1 `src/paypal/paypal.md` — Purpose / Features / Basic + Advanced Usage / API Reference / Implementation Notes (≥200 words)
- [x] 4.2 `README.md` — install / quick-start / Modules links / migration
- [x] 4.3 No `CLAUDE.md` entry required (per CLAUDE.md doc-policy note — sibling-plugin packages are documented through `MANIFEST.md` / `STATUS.md` / `SUMMARY.md` and the per-package `.md` files)
## 5. Pre-archive verification (the 5-gate triple)
- [x] 5.1 `bun run check` — Biome 0/0/0 across the monorepo
- [x] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/payment-provider-paypal` — green
- [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/payment-provider-paypal` — 100/100/100/100
- [x] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/payment-provider-paypal` — exit 0, no `error` findings
- [x] 5.5 `bunx turbo build --filter=@suaveplan/payment-provider-paypal` — green
## 6. Pre-archive 7-row checklist (AGENTS.md §13)
- [x] 6.1 Generics threaded (`PayPalProvider.name` is the literal `"paypal"`; `httpRequest<T>` generics threaded through every call site)
- [x] 6.2 Zod schemas wired at every declared boundary — N/A (this adapter consumes the slim core's typed `httpRequest` and the `@suaveplan/payment` interface; no public Zod boundary beyond the structural `OAuthConfig` extension)
- [x] 6.3 Every error code reachable: `OAUTH_TOKEN_FAILURE` raised by token-fetch failure path; `HTTP_ERROR` / `TIMEOUT` / `PARSE_ERROR` reachable transitively via `httpRequest`; tested in both directions
- [x] 6.4 Strict-mode behaviors — `sandbox` flag both on and off; token cache hit AND refresh; refund with AND without amount/idempotency; createIntent with AND without idempotency
- [x] 6.5 OTel instruments — N/A; deferred per the slim core's matching deferral until `@suaveplan/payment` lands an observability surface
- [x] 6.6 Lifecycle dedup — token cache reuse asserted (single token call across two intents); refresh-after-expiry asserted
- [x] 6.7 No retroactive tick — every box above corresponds to work done in this change
## 7. Archive
- [x] 7.1 Fold spec delta into `openspec/specs/payment-provider-paypal/spec.md`
- [x] 7.2 Move `openspec/changes/add-payment-provider-paypal/` → `openspec/archive/2026-05-17-add-payment-provider-paypal/`
- [x] 7.3 Refresh `MANIFEST.md`, `MISSING.yml`, `STATUS.md`, `SUMMARY.md`