By default, the Ticket Number is assigned when a Ticket is Closed (ie. Orders are Submitted), whether Paid or Not. If you want to assign the Ticket Number when a Ticket is fully Paid, you will need to handle that using custom Automation.
Here is a Tutorial that shows how to track your own “Invoice” number(s)…
That ^ Tutorial leaves the normal default Ticket Number generation intact, which is something that you don’t want to be messing with. However, it behaves in the same way as default Ticket Number generation, in that it assigns/updates the Invoice Number when a Ticket is Closed.
You will need to modify it to suit your needs, that is, you need to change the Rules when the Invoice Number is generated/updated and applied. As is, the Rules are triggered for the events of Before Ticket Closing (invoice number generated//updated) and Ticket Closing (invoice number applied to ticket as a Tag and State).
You should change both of those Rules so that they contain another Constraint to check for Remaining Amount Equals 0
…