I wanted to figure out how people build payment systems without losing everyone's money. It turns out, my first attempt was a great way to lose a lot of it. I started with what felt like a simple Go service. One endpoint, one database table, and a third-party provider to handle the actual charging. The plan was straightforward: Decode the request. Call the provider to charge the user. Save the result to my database. Respond with a 201. It looked like this: func ( s Server ) createCharge ( w http . ResponseWriter , r * http . Request ) { ctx := r . Context () var req createChargeRequest if err := decodeJSON ( r , & req ); err != nil { writeError ( w , http . StatusBadRequest , err . Error ()) return } // 1. Charge the user if err := s . paymentProvider . Charge ( ctx , provider . CreateCharge { Amount : req . Amount , Currency : req . Currency , Reference : req . Reference , }); err != nil { writeError ( w , http . StatusBadRequest , err . Error ()) return } // 2. Record it in the DB c , err := s .…