require_once dirname(__FILE__) . "/../config.php"; require_once dirname(__FILE__) . "/../../contractors/ContractorsApiWebHooks.class.php"; require_once dirname(__FILE__) . "/../../transactions/TransactionsApiWebHooks.class.php"; require_once dirname(__FILE__) . "/../../protection/ProtectionApiWebHooks.class.php"; require_once dirname(__FILE__) . "/../../liabilities/LiabilitiesApiWebHooks.class.php"; Logger::setWriter(new FileLoggerWriter(dirname(__FILE__) . '/Listener.log.txt')); $client = new WebHooksClient(INVIPAY_PARTNER_API_KEY, INVIPAY_PARTNER_SIGNATURE_KEY); // Note that here we're using PARTNER account so we can listen to events issued on behalf of other Contractors related to our platform $client->onEvent(ContractorsApiWebHooks::getDefinition('ContractorVerificationCompletedEvent'), 'onContractorVerificationCompletedEvent'); $client->onEvent(ContractorsApiWebHooks::getDefinition('AccountCreationCompletedEvent'), 'onAccountCreationCompletedEvent'); $client->onEvent(ContractorsApiWebHooks::getDefinition('ContractorProfileChangedEvent'), 'onContractorProfileChangedEvent'); $client->onEvent(TransactionsApiWebHooks::getDefinition('TransactionDeletedEvent'), 'onTransactionDeletedEvent'); $client->onEvent(ProtectionApiWebHooks::getDefinition('TransactionProtectionCompletedEvent'), 'onTransactionProtectionCompletedEvent'); $client->onEvent(LiabilitiesApiWebHooks::getDefinition('NewCommissionInvoiceCreatedEvent'), 'onNewCommissionInvoiceCreatedEvent'); $client->onEvent(LiabilitiesApiWebHooks::getDefinition('NewInterestInvoiceCreatedEvent'), 'onNewInterestInvoiceCreatedEvent'); $client->onEvent(LiabilitiesApiWebHooks::getDefinition('NewInterestNoteCreatedEvent'), 'onNewInterestNoteCreatedEvent'); $client->handle(); function onContractorVerificationCompletedEvent($data) { Logger::info('Contractor verification completed with data: {0}', $data); } function onAccountCreationCompletedEvent($data) { Logger::info('Account creation completed with data: {0}', $data); } function onContractorProfileChangedEvent($data) { Logger::info('Contractor profile changed with data: {0}', $data); } function onTransactionDeletedEvent($data) {
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ require_once dirname(__FILE__) . "/../common/WebHookDefinition.class.php"; require_once dirname(__FILE__) . "/dto/InterestInvoiceDetails.class.php"; require_once dirname(__FILE__) . "/dto/InterestNoteDetails.class.php"; require_once dirname(__FILE__) . "/dto/CommissionInvoiceDetails.class.php"; class LiabilitiesApiWebHooks { const NewCommissionInvoiceCreatedEvent = 'NewCommissionInvoiceCreatedEvent'; const NewInterestInvoiceCreatedEvent = 'NewInterestInvoiceCreatedEvent'; const NewInterestNoteCreatedEvent = 'NewInterestNoteCreatedEvent'; private static $mapping = array(); public static function initialize() { self::$mapping[self::NewCommissionInvoiceCreatedEvent] = new WebHookDefinition(self::NewCommissionInvoiceCreatedEvent, new CommissionInvoiceDetails()); self::$mapping[self::NewInterestInvoiceCreatedEvent] = new WebHookDefinition(self::NewInterestInvoiceCreatedEvent, new InterestInvoiceDetails()); self::$mapping[self::NewInterestNoteCreatedEvent] = new WebHookDefinition(self::NewInterestNoteCreatedEvent, new CommissionInvoiceDetails()); } public static function getDefinition($key) { if (!array_key_exists($key, self::$mapping)) { throw new Exception('WebHook event definition for [' . $key . '] not found.'); } return self::$mapping[$key]; } } LiabilitiesApiWebHooks::initialize();