How to generate an invoice after payment