execute php script on payment (and overdue)

You can use a subscription to run a script when a payment is entered.

http://docs.invoiceninja.com/en/latest/api.html#subscriptions