vimeo / payment-gateway-logger
Logging capabilities for Omnipay gateways
Installs: 143 409
Dependents: 2
Suggesters: 0
Security: 0
Stars: 4
Watchers: 15
Forks: 5
Open Issues: 0
pkg:composer/vimeo/payment-gateway-logger
Requires
- guzzlehttp/guzzle: ^6.5|^7.8
- omnipay/common: ^3.0
- psr/log: ^1.0
Requires (Dev)
- omnipay/tests: 3.0
This package is auto-updated.
Last update: 2025-10-11 01:35:13 UTC
README
Package is installed via Composer. To install, simply add it to your composer.json file:
{
    "require": {
        "vimeo/payment-gateway-logger": "^1.0"
    }
}
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
Usage
Logging capabilities for Omnipay gateways via an EventSubscriberInterface subscriber for Omnipay payment gateway-specific events.
These events are dispatched via the HTTP client's EventDispatcherInterface.
- 
The omnipay gateway needs to be updated to emit any of the RequestEvent,ResponseEventorErrorEventobjects. For example in the gateway'ssendData()methods we can do:$event_dispatcher = $this->httpClient->getEventDispatcher(); $event_dispatcher->dispatch(Constants::OMNIPAY_REQUEST_BEFORE_SEND, new RequestEvent($request)); Logging Errors and Responses events can be emitted like so $event_dispatcher->dispatch(Constants::OMNIPAY_REQUEST_ERROR new ErrorEvent($exception, $request)); $event_dispatcher->dispatch(Constants::OMNIPAY_RESPONSE_SUCCESS, new ResponseEvent($response)); 
OmnipayGatewayRequestSubscriber.php takes in a logger of type LoggerInterface which will listen to and log these events.
The subscriber can be set up to listen to these events when instantiating the HTTP client for the gateway like so:
$httpClient = new GuzzleClient(); $gateway = Omnipay::create('Vindicia', $httpClient); $eventDispatcher = $httpClient->getEventDispatcher(); $eventDispatcher->addSubscriber(new OmnipayGatewayRequestSubscriber($gateway_name, new LoggerClassThatImplementsPSRInterface()));