Yes, this is possible to do via script and get Balance Due data from API2.
But i think, this is very risky, we must make sure the balance due are correct before sending them to third parties. And this is only suitable for businesses that do real-time recording.