Save week10.py in your exercise folder and run python week10.py --lesson 3. The lab creates a temporary SQLite ledger, a synthetic approval, and a durable operation record. It commits one permitted refund, closes and reopens the database, then redelivers the same logical request. The stored result is returned with no second refund.
hashlib provides standard digest functions. json.dumps with sort_keys=True gives a stable field order, and encode converts text to bytes before hashing:
import hashlib, json
action = {"order": "O7", "cents": 500, "destination": "original"}
encoded = json.dumps(action, sort_keys=True).encode("utf-8")
fingerprint = hashlib.sha256(encoded).hexdigest()
assert len(fingerprint) == 64
The hash is not encryption; the original values still need appropriate storage controls. The lab rejects changed amounts, a changed destination, an expired approval, and a read-only caller. PASS means one synthetic ledger effect and correctly denied alternatives, not a real refund or a complete production payment integration.