https://github.com/adyen/php-webhook-module
PHP Webhook Helper Module for Adyen Payment Integrations
https://github.com/adyen/php-webhook-module
adyen payment-integration php webhook
Last synced: 12 months ago
JSON representation
PHP Webhook Helper Module for Adyen Payment Integrations
- Host: GitHub
- URL: https://github.com/adyen/php-webhook-module
- Owner: Adyen
- License: mit
- Created: 2021-03-17T12:08:50.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2025-07-14T07:11:54.000Z (12 months ago)
- Last Synced: 2025-07-17T21:10:32.344Z (12 months ago)
- Topics: adyen, payment-integration, php, webhook
- Language: PHP
- Homepage:
- Size: 127 KB
- Stars: 6
- Watchers: 7
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Webhook Module for PHP
Adyen library for handling notification webhooks.
## Installation
You can use [Composer](https://getcomposer.org/). Follow the [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have Composer installed.
~~~~ bash
composer require adyen/php-webhook-module
~~~~
In your PHP script, make sure to include the autoloader:
~~~~ php
require __DIR__ . '/vendor/autoload.php';
~~~~
Alternatively, you can download the [release on GitHub](https://github.com/Adyen/php-webhook-module/releases).
## Usage
#### Authenticate and validate incoming webhook request:
~~~~ php
// Setup NotificationReceiver with dependency injection or create an instance as follows
$notificationReceiver = new \Adyen\Webhook\Receiver\NotificationReceiver(new \Adyen\Webhook\Receiver\HmacSignature);
// Authorize notification
if (!$notificationReceiver->isAuthenticated(
$request['notificationItems'][0]['NotificationRequestItem'],
YOUR_MERCHANT_ACCOUNT,
YOUR_NOTIFICATION_USERNAME,
YOUR_NOTIFICATION_PASSWORD
)) {
throw new AuthenticationException();
}
// Process each notification item
foreach ($request['notificationItems'] as $notificationItem) {
// validate the notification
if ($notificationReceiver->validateHmac($notificationItem, YOUR_HMAC_KEY)) {
// save notification to your database
$this->databaseService->saveNotification($notificationItem);
}
}
return new JsonResponse('[accepted]');
~~~~
#### Process notification to get new payment state:
~~~~ php
$notificationItem = \Adyen\Webhook\Notification::createItem([
'eventCode' => $notification['eventCode'],
'success' => $notification['success']
]);
$processor = \Adyen\Webhook\Processor\ProcessorFactory::create(
$notificationItem,
$currentPaymentState,
$this->logger
);
$newState = $processor->process();
~~~~
NB: set `$currentPaymentState` to one of the values in `\Adyen\Webhook\PaymentStates`
## Documentation
Visit our [documentation page](https://docs.adyen.com/development-resources/webhooks/understand-notifications) to learn more about handling notifications.
## Contributing
We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements.
Have a look at our [contributing guidelines](https://github.com/Adyen/.github/blob/develop/CONTRIBUTING.md) to find out how to raise a pull request.
## Support
If you have a feature request, or spotted a bug or a technical problem, [create an issue here](https://github.com/Adyen/php-webhook-module/issues/new/choose).
For other questions, [contact our Support Team](https://www.adyen.help/hc/en-us/requests/new?ticket_form_id=360000705420).
## Licence
This repository is available under the [MIT license](https://github.com/Adyen/php-webhook-module/blob/master/LICENSE).