Skip to content

feat(types): echo checkout_session_id on PayResult#105

Merged
dangazineu merged 1 commit into
mainfrom
feat/payresult-checkout-correlation
Jun 28, 2026
Merged

feat(types): echo checkout_session_id on PayResult#105
dangazineu merged 1 commit into
mainfrom
feat/payresult-checkout-correlation

Conversation

@dangazineu

Copy link
Copy Markdown
Contributor

What

Add an optional checkout_session_id to PayResult (@codespar/types), and document the codespar_pay correlation in the contract doc.

When an agent drives a purchase as two steps — codespar_shop to reach ready_for_payment, then the payment tool to settle the pix_copia_e_cola — the PayResult it gets back today says nothing about which checkout it settled. Echoing the checkout_session_id gives a caller the join key to correlate the two calls without reaching into server-internal state.

Shape

export interface PayResult {
  // ...existing fields unchanged...
  pix_copy_paste?: string;
  checkout_session_id?: string; // NEW: the checkout this payment settled (join key)
  raw?: unknown;
}

Why it's safe (additive, v0 rule)

  • New optional field; no existing field is removed, renamed, or re-typed.
  • A direct payment with no originating checkout leaves it unset; consumers that ignore it are unaffected.
  • The merchant pix_copia_e_cola the checkout carried is deliberately NOT echoed here — it is a payable bearer instrument and is kept out of results and logs (PII / Pix log-redaction).

Scope note (3-way edit)

PayResult is TypeScript-only today (no Python dataclass mirror in types.py), so this is a TS-types + backend-route change. Bringing codespar_pay's types to the TS/Python parity the shop types already have is tracked as separate follow-up work.

Verification

npm run typecheck and npm test green in packages/types (82 tests).

Draft pending the consuming backend change and a @codespar/types publish.

Add an optional checkout_session_id to PayResult so a payment that settled a
checkout carries the join key back to that checkout. When an agent drives a
purchase as two steps (codespar_shop to ready_for_payment, then the payment
tool to settle the pix_copia_e_cola), the result it gets back today says
nothing about which checkout it belongs to. Echoing the checkout id lets a
caller correlate the two calls without reaching into server-internal state.

The field is additive and optional under the v0 additive-compatibility rule:
existing consumers that ignore it are unaffected, and a direct payment with no
originating checkout leaves it unset. The merchant pix_copia_e_cola the
checkout carried is deliberately NOT echoed -- it is a payable bearer
instrument and is kept out of results and logs.

PayResult is TypeScript-only today (no Python dataclass mirror), so this is a
TS-types + backend-route change; documents the codespar_pay correlation in the
contract doc and notes Python parity as follow-up.

typecheck + tests green in packages/types.
@dangazineu
dangazineu marked this pull request as ready for review June 28, 2026 14:25
@dangazineu
dangazineu merged commit 6c01790 into main Jun 28, 2026
9 checks passed
dangazineu added a commit that referenced this pull request Jun 28, 2026
Bump @codespar/types to 0.10.13 to publish the additive
PayResult.checkout_session_id field merged in #105. 0.10.12 is already on
the registry, so the field ships in the next patch. Tagging v0.10.13 after
merge triggers the publish workflow (OIDC trusted publishing).
dangazineu added a commit that referenced this pull request Jun 28, 2026
Single release of @codespar/types at the next free version, 0.10.13. Consolidates
two additive changes already on main, plus the manifest bump they require:

- PayResult.checkout_session_id (merged in #105)
- the payment-failure-triage demo scenarios + DEMO_SCENARIO_MANIFEST (merged in
  #103)

0.10.12 was published in parallel by unrelated work and predates both, so this
ships at 0.10.13. Bumps packages/types/package.json AND
DEMO_SCENARIO_MANIFEST.version in lockstep (the manifest self-test enforces
equality with the package version — a package-only bump like #106 would fail it).
Supersedes #106. After merge, tagging v0.10.13 publishes the package; the example
(#104) and the managed parity test (#402) pin 0.10.13.
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