Skip to content

Commit

Permalink
Release 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wallee-deployment-user committed Jan 25, 2024
1 parent 4dfad73 commit b193efa
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023 wallee AG
Copyright 2024 wallee AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,44 @@ putenv('WLE_HTTP_CLIENT=curl');
?>
```

### Integrating Webhook Payload Signing Mechanism into webhook callback handler

The HTTP request which is sent for a state change of an entity now includes an additional field `state`, which provides information about the update of the monitored entity's state. This enhancement is a result of the implementation of our webhook encryption mechanism.

Payload field `state` provides direct information about the state update of the entity, making additional API calls to retrieve the entity state redundant.

#### ⚠️ Warning: Generic Pseudocode

> **The provided pseudocode is intentionally generic and serves to illustrate the process of enhancing your API to leverage webhook payload signing. It is not a complete implementation.**
>
> Please ensure that you adapt and extend this code to meet the specific needs of your application, including appropriate security measures and error handling.
For a detailed webhook payload signing mechanism understanding we highly recommend referring to our comprehensive
[Webhook Payload Signing Documentation](https://app-wallee.com/doc/webhooks#_webhook_payload_signing_mechanism).

```php
public function handleWebhook() {
$requestPayload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';

if (empty($signature)) {
// Make additional API call to retrieve the entity state
// ...
} else {
if ($client->getWebhookEncryptionService()->isContentValid($signature, $requestPayload)) {
// Parse requestPayload to extract 'state' value
// $state = ...
// Process entity's state change
// $this->processEntityStateChange($state);
// ...
}
}

// Process the received webhook data
// ...

}
```

## License

Please see the [license file](https://github.com/wallee-payment/php-sdk/blob/master/LICENSE) for more information.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wallee/sdk",
"version": "4.0.2",
"version": "4.1.0",
"description": "wallee SDK for PHP",
"keywords": [
"wallee",
Expand Down
4 changes: 2 additions & 2 deletions lib/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class ApiClient {
* @var array
*/
private $defaultHeaders = [
'x-meta-sdk-version' => "4.0.2",
'x-meta-sdk-version' => "4.1.0",
'x-meta-sdk-language' => 'php',
'x-meta-sdk-provider' => "wallee",
];
Expand All @@ -58,7 +58,7 @@ final class ApiClient {
*
* @var string
*/
private $userAgent = 'PHP-Client/4.0.2/php';
private $userAgent = 'PHP-Client/4.1.0/php';

/**
* The path to the certificate authority file.
Expand Down
6 changes: 3 additions & 3 deletions lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Configuration
*
* @var string
*/
protected $userAgent = 'Wallee\Sdk/4.0.2/php';
protected $userAgent = 'Wallee\Sdk/4.1.0/php';

/**
* Debug switch (default set to false)
Expand Down Expand Up @@ -388,8 +388,8 @@ public static function toDebugReport()
$report = 'PHP SDK (Wallee\Sdk) Debug Report:' . PHP_EOL;
$report .= ' OS: ' . php_uname() . PHP_EOL;
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
$report .= ' OpenAPI Spec Version: 4.0.2' . PHP_EOL;
$report .= ' SDK Package Version: 4.0.2' . PHP_EOL;
$report .= ' OpenAPI Spec Version: 4.1.0' . PHP_EOL;
$report .= ' SDK Package Version: 4.1.0' . PHP_EOL;
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;

return $report;
Expand Down
2 changes: 1 addition & 1 deletion test/ApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function testSdkHeaders()
$this->assertGreaterThanOrEqual(4, count($headers));

// Check SDK default header values.
$this->assertEquals($headers['x-meta-sdk-version'], "4.0.2");
$this->assertEquals($headers['x-meta-sdk-version'], "4.1.0");
$this->assertEquals($headers['x-meta-sdk-language'], 'php');
$this->assertEquals($headers['x-meta-sdk-provider'], "wallee");
$this->assertEquals($headers['x-meta-sdk-language-version'], phpversion());
Expand Down

0 comments on commit b193efa

Please sign in to comment.