Description
Multi-recipient split payments consist of several payment operations grouped in one transaction, but when a partial failure occurs at the application layer (e.g. post-submission webhook failure, database write failure), the SDK provides no mechanism to track which portions of the split were acknowledged and coordinate a corrective resubmission or reversal. A rollback coordinator should record split state atomically and provide a reconciliation primitive.
Technical Context
Add src/splitRollbackCoordinator.ts. Integrates with src/snapshot.ts for state persistence. Reads SplitResult and SplitLeg from src/types.ts. Uses src/idempotency.ts to prevent double-reversal. Hooks into src/client.ts submitPayment() post-submission lifecycle. Emits splitRollbackInitiated and splitRollbackCompleted via src/events.ts.
Acceptance Criteria
Description
Multi-recipient split payments consist of several payment operations grouped in one transaction, but when a partial failure occurs at the application layer (e.g. post-submission webhook failure, database write failure), the SDK provides no mechanism to track which portions of the split were acknowledged and coordinate a corrective resubmission or reversal. A rollback coordinator should record split state atomically and provide a reconciliation primitive.
Technical Context
Add
src/splitRollbackCoordinator.ts. Integrates withsrc/snapshot.tsfor state persistence. ReadsSplitResultandSplitLegfromsrc/types.ts. Usessrc/idempotency.tsto prevent double-reversal. Hooks intosrc/client.tssubmitPayment()post-submission lifecycle. EmitssplitRollbackInitiatedandsplitRollbackCompletedviasrc/events.ts.Acceptance Criteria
RollbackCoordinator.begin(splitId)creates a persistent rollback checkpoint recording all intended split legsRollbackCoordinator.markLegSuccess(splitId, legIndex)andmarkLegFailed(splitId, legIndex)update the checkpoint atomicallyRollbackCoordinator.getIncomplete(splitId)returns the set of legs that neither succeeded nor are confirmed failedRollbackCoordinator.initiateRollback(splitId)emitssplitRollbackInitiatedand stores a rollback record insrc/snapshot.tsinitiateRollback, and asserts the checkpoint reflects the correct incomplete legs