Added support for failed and check if invoice was paid. Log to db