Optimal Solutions for Online Payment Collection and Invoicing