2017 © Pedro Peláez
 

library gocardless-webhook

Process webhooks from GoCardless

image

ockle/gocardless-webhook

Process webhooks from GoCardless

  • Friday, January 27, 2017
  • by ockle
  • Repository
  • 1 Watchers
  • 2 Stars
  • 974 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

GoCardless Webhook

Build Status Coverage Status, (*1)

A PHP library to aid is the processing of webhooks from GoCardless (see API documentation for more information)., (*2)

Installation

Install the library using Composer. Add the following to your composer.json:, (*3)

{
    "require": {
        "ockle/gocardless-webhook": "~1.0"
    }
}

and then run:, (*4)

composer update ockle/gocardless-webhook

Usage

Instantaiate a new webhook service:, (*5)

// $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);

Then attach event listeners, e.g.:, (*6)

$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();
});

Next, process the webhook, which will trigger your event listeners as necessary:, (*7)

$webhook->process($webhookSignatureFromHeaders, $rawPostBody);

Finally, return the correct HTTP status code is your response, which can be got by calling:, (*8)

$webhook->getResponseStatus();

License

MIT, (*9)

The Versions

27/01 2017

dev-master

9999999-dev

Process webhooks from GoCardless

  Sources   Download

MIT

The Requires

 

The Development Requires

27/01 2017

v1.0.3

1.0.3.0

Process webhooks from GoCardless

  Sources   Download

MIT

The Requires

 

The Development Requires

27/01 2017

v1.0.2

1.0.2.0

Process webhooks from GoCardless

  Sources   Download

MIT

The Requires

 

The Development Requires

05/12 2015

v1.0.1

1.0.1.0

Process webhooks from GoCardless

  Sources   Download

MIT

The Requires

 

The Development Requires

01/12 2015

v1.0.0

1.0.0.0

Process webhooks from GoCardless

  Sources   Download

MIT

The Requires

 

The Development Requires