Handling AI agent refunds without paying twice: signatures, idempotency and limits in TypeScript
AI assistants are starting to call businesses' systems on behalf of their users: "return the blue jacket", "move my appointment to Thursday". Reading an order is harmless. A refund moves money, and that's where the interesting engineering is. Here are the four failure modes I'd design for first, with the TypeScript I use for each. The examples use allowfy, a small open-source package (zero dependencies, Web Request/Response), but the patterns apply to any webhook-based integration. Your refund…