I built this on NestJS. Cron jobs schedule the invoices, BullMQ workers process them, and retries and duplicate prevention live in their own layer. I also built the test harness for it: a MongoDB replica set, Redis and a mocked gateway, with cases for missing card, failed payment, post-processing failure, duplicate invoices and retry billing.