"""verify_receipt.py URL - check an AtlasClose TEST receipt yourself (Python 3 stdlib only). python3 verify_receipt.py https://demo.atlasclose.com/pay/r/TEST-ATL-M-2026-0001 Downloads .json, re-computes every docket entry hash and link, and checks that the receipt's commencement, delivery and receipt entries (C5) are in that chain with the same hashes. Prints OK or FAIL and exits 0 or 1.""" import hashlib, json, sys, urllib.request def check(doc): prev, ok, by = "0" * 64, True, {} for e in doc["entries"]: body = {k: v for k, v in e.items() if k != "sha"} h = hashlib.sha256(json.dumps(body, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()).hexdigest() ok = ok and h == e["sha"] and e["matter_prev_sha"] == prev prev = e["sha"] by[e["seq"]] = e links = {} for k in ("commencement", "delivery", "receipt"): x = (doc.get("receipt") or {}).get("C5", {}).get(k) links[k] = None if x is None else (x["seq"] in by and by[x["seq"]]["sha"] == x["sha256"]) return ok and all(v is not False for v in links.values()), ok, links if __name__ == "__main__": url = sys.argv[1].rstrip("/") req = urllib.request.Request(url + ".json", headers={"User-Agent": "atlasclose-verify-receipt/1", "Cache-Control": "no-cache"}) doc = json.loads(urllib.request.urlopen(req, timeout=20).read()) allok, chain, links = check(doc) print("%s chain=%s entries=%d links=%s" % ("OK" if allok else "FAIL", chain, len(doc["entries"]), json.dumps(links))) sys.exit(0 if allok else 1)