-
Notifications
You must be signed in to change notification settings - Fork 0
Session API #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session API #10
Conversation
fix!: align Session API with official Satispay specification BREAKING CHANGE: Session event operations updated - Changed `type` → `operation` in session events - Changed `SessionEventType` → `SessionEventOperation` - Replaced 'ADD_ITEM'/'REMOVE_ITEM' with 'ADD'/'REMOVE' - Removed 'UPDATE_TOTAL' operation (not supported by API) - Made `currency` field mandatory in SessionEventCreateBody - Fixed Pre-Authorized Payment Tokens documentation - Removed duplicate "Create a Payment" section in README - Added E2E tests for fund lock payments
WalkthroughThis PR implements breaking changes to the Session API to align with official Satispay documentation. The session event type field is renamed to operation with simplified values (ADD/REMOVE), currency becomes mandatory, and amount_unit becomes required. Documentation, examples, tests, and a new E2E test for fund lock payments are updated accordingly. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes Areas requiring extra attention:
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
CHANGELOG.md (1)
8-26: Call outamount_unitrequirement as part of the breaking changeChangelog correctly documents the rename to
operationand the new mandatorycurrencyfield, butSessionEventCreateBody.amount_unitis now also required insrc/types.ts. Consider adding a bullet explicitly stating thatamount_unitbecame mandatory to fully describe the breaking surface for session events.src/Session.ts (1)
128-158: Clarify wording now that only ADD/REMOVE operations existThe examples correctly use
operation: 'ADD' | 'REMOVE'and includecurrency, matching the new types. The JSDoc remark above still says “add, remove, or update items,” which might suggest a thirdUPDATEoperation that no longer exists. Consider rephrasing to something like “Events are used to add or remove items in a POS session; each event updates the total amount…” to avoid implying an unsupported operation.tests/e2e/session.e2e.test.ts (1)
1-67: Well-scoped E2E test; condition helpers could be simplifiedThe fund lock E2E flow (create → assert fields → get → assert fields) is coherent and guarded behind environment checks, which is appropriate for real API calls. Since
hasAuthenticationKeys()currently just proxiescanRunE2ETests(), you could simplify thedescribe.skipIfcondition to a single helper or differentiate their responsibilities, but that’s purely cosmetic.tests/Session.test.ts (1)
176-281: Session.createEvent tests cover new payload shape wellThe updated tests for
createEventcorrectly:
- Use
operation: 'ADD' | 'REMOVE'instead of the old type field.- Include mandatory
currency: 'EUR'.- Verify both full payloads and nested
metadatawhere relevant.If you want to harden the “with metadata” case further, you could extend the
expect.objectContainingto also assertoperationandcurrency, but given the other tests already cover those fields, this is optional.README.md (2)
15-16: Updated bundle size notes are consistentThe “Lightweight” feature and “Why Zero Dependencies?” sections now both reference a 268KB bundle, which keeps the messaging consistent. Just keep in mind these hard-coded numbers will need updating if the bundle grows again.
Also applies to: 600-602
544-544: Coverage numbers updated; ensure they stay in sync with reportsThe coverage line reflects significantly higher coverage (94.82%). Looks good, but remember to refresh this value periodically from actual reports so it doesn’t drift.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
CHANGELOG.md(2 hunks)README.md(5 hunks)examples/pos-session.ts(1 hunks)src/Session.ts(2 hunks)src/types.ts(2 hunks)tests/Session.test.ts(2 hunks)tests/e2e/session.e2e.test.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
tests/e2e/session.e2e.test.ts (1)
tests/setup.ts (2)
canRunE2ETests(49-55)hasAuthenticationKeys(61-63)
tests/Session.test.ts (2)
src/types.ts (2)
SessionEventCreateBody(317-323)SessionResponse(295-305)src/Session.ts (1)
Session(41-174)
examples/pos-session.ts (1)
src/Session.ts (1)
Session(41-174)
🔇 Additional comments (7)
CHANGELOG.md (1)
88-90: Version compare links look consistentThe new compare links for v0.0.4, v0.0.3, and v0.0.2 are coherent with the existing style and should work as expected.
src/Session.ts (1)
27-32: Session open example aligned with new APIExample now uses
operation: 'ADD'and includescurrency: 'EUR', consistent withSessionEventCreateBody. No issues here.src/types.ts (2)
66-68: Session event operation type matches documented surface
SessionEventOperation = 'ADD' | 'REMOVE'reflects the simplified operation set and aligns with the updated examples/tests. Looks good.
317-323: SessionEventCreateBody shape is coherent with usageRequiring
operation,amount_unit, andcurrencyhere matches how events are created inSession.createEvent, the examples, and the tests. Aside from ensuring the changelog fully documents these required fields (already noted there), the type definition itself looks solid.README.md (2)
227-264: Pre-Authorized Payment Tokens docs nicely aligned with typesThis section now clearly documents:
- Creation parameters (
reason,callback_url,redirect_url).- Retrieval and update (including
status: 'CANCELED').- Downstream usage in
Payment.createwithflow: 'PRE_AUTHORIZED'andtoken: token.token.- Status semantics and the “use token, not id” guidance.
All of this matches the corresponding type definitions and intended flow.
315-331: Session examples match the new SessionEventCreateBodyThe Session examples now use:
operation: 'ADD' | 'REMOVE'instead of the old type values.- Explicit
currency: 'EUR'on each event.amount_unitin cents as elsewhere.This keeps the README in sync with
SessionEventCreateBodyand the runtime behavior.examples/pos-session.ts (1)
70-111: POS session example correctly demonstrates ADD/REMOVE operationsThe example’s
Session.createEventcalls now useoperation: 'ADD' | 'REMOVE'withamount_unitin cents andcurrency: 'EUR', matching the new API and types. The item/discount amounts and comments are consistent, so this should be a very clear reference for integrators.



fix!: align Session API with official Satispay specification
BREAKING CHANGE: Session event operations updated
type→operationin session eventsSessionEventType→SessionEventOperationcurrencyfield mandatory in SessionEventCreateBodySummary by CodeRabbit
Breaking Changes
typerenamed tooperationwith new values ('ADD', 'REMOVE')New Features
Bug Fixes
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.