1. Go to this page and download the library: Download ockle/gocardless-webhook library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ockle / gocardless-webhook example snippets
// $secret is the string entered in the GoCardless admin when setting up a webhook endpoint
$webhook = new \Ockle\GoCardlessWebhook\Service($secret, new \Symfony\Component\EventDispatcher\EventDispatcher);
$webhook->onMandate(function (\Ockle\GoCardlessWebhook\Events\MandateEvent $event) use ($client) {
// Do stuff when a mandate event occurs
// You can check what the action is:
if ($event->actionIs(\Ockle\GoCardlessWebhook\Events\MandateEvent::ACTION_CREATED)) {
// Mandate has been created
}
// However, it is advised that you don't do any important business logic based off this, but
// rather do an API call to get the current status of the mandate and act on that as the accurate
// source of mandate information. This is due to the fact that events may be received in any order.
// There are methods to get information about the event, e.g.:
$mandateId = $event->getMandateId();
});