Repository navigation
Demo 13: saga under a slow payment - #16
Merged
Merged
Conversation
…e undo, pending orders A LinkedIn reader pointed out the saga's dangerous case: a charge that times out may have gone through, and releasing the stock then leaves a customer charged with no order. - Every charge carries the saga id as its idempotency key; a retry returns the first charge, and a reused key with a different amount answers 409. - Payment records PROCESSING before the slow part. After a timeout the saga voids the key (POST /api/payment/charges/<key>/void): an unseen key becomes VOIDED, so a late charge is refused; a charge stuck in PROCESSING for 30 s is voided; anything else is returned as it stands. - APPROVED confirms the order, DECLINED (402) or VOIDED (503) releases the stock, PROCESSING or no answer leaves the order pending with the stock held. reconcile.py settles pending orders every 5 s. - Demo page /patterns/slow-payment, Pact contract updated, smoke tests for both outcomes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A reader of the LinkedIn post raised the saga's dangerous case: payment times out, the breaker counts a failure, the saga releases the stock, and the customer was charged anyway. The two fixes he named are built here.
What changed
POST /api/payment/charges/<key>/void:/patterns/slow-paymentshows where the money and the stock end up.Tests
🤖 Generated with Claude Code