Skip to content

Commit

Permalink
Release 1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrowanwallee committed Jun 17, 2024
1 parent c8aa449 commit 4eefab8
Show file tree
Hide file tree
Showing 575 changed files with 2,987 additions and 2,945 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PrestaShop 8 wallee Integration
This repository contains the PrestaShop wallee payment module that enables the shop to process payments with [wallee](https://www.wallee.com).

## To install module manually by dragging up zip file, please download [.zip archive](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.6/wallee.zip) of module with correct structure required by Prestashop installation
## To install module manually by dragging up zip file, please download [.zip archive](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.7/wallee.zip) of module with correct structure required by Prestashop installation

##### To use this extension, a [wallee](https://app-wallee.com/user/signup) account is required.

Expand All @@ -12,15 +12,15 @@ This repository contains the PrestaShop wallee payment module that enables the s

## Documentation

* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.6/docs/en/documentation.html)
* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.7/docs/en/documentation.html)

## Support

Support queries can be issued on the [wallee support site](https://app-wallee.com/space/select?target=/support).

## License

Please see the [license file](https://github.com/wallee-payment/prestashop-8/blob/1.0.6/LICENSE) for more information.
Please see the [license file](https://github.com/wallee-payment/prestashop-8/blob/1.0.7/LICENSE) for more information.

## Other PrestaShop Versions

Expand Down
22 changes: 21 additions & 1 deletion controllers/front/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ private function processFailure(Order $order)
if (! empty($userFailureMessage)) {
$this->context->cookie->wle_error = $userFailureMessage;
}

$this->setCurrentState($order);

$order->setCurrentState(Configuration::get(WalleeBasemodule::CK_STATUS_FAILED));
//the new state should be saved here to override the stock issues of incrementing or decrementing items when going through the webhooks
//by calling the setCurrentState function more than once without saving.
$order->save();
Expand All @@ -116,6 +117,25 @@ public function setMedia()
{
// We do not need styling here
}

/**
* @param Order $order
* @return void
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
protected function setCurrentState(Order $order): void
{
$newState = Configuration::get(WalleeBasemodule::CK_STATUS_FAILED);
$history = new OrderHistory();
$history->id_order = $order->id;
$history->id_order_state = $newState;
$history->id_employee = (int)Context::getContext()->employee->id;
$history->date_add = date('Y-m-d H:i:s');
$history->add();

$order->current_state = $newState;
}

protected function displayMaintenancePage()
{
Expand Down
4 changes: 2 additions & 2 deletions docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.6/">
<a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.7/">
Source
</a>
</li>
Expand All @@ -50,7 +50,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.6/">Download</a> the module.</p>
<p><a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.7/">Download</a> the module.</p>
</li>
<li>
<p>Login to the backend of your PrestsShop store.</p>
Expand Down
2 changes: 1 addition & 1 deletion views/templates/admin/admin_help_buttons.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<div class="alert alert-info">
<img src="../modules/wallee/logo.png" style="float:left; margin-right:15px;" height="50">
<p><strong>{l s='This module requires an %s account.' sprintf='wallee' mod='wallee'}</strong></p>
<p><a class="btn btn-default" href="https://app-wallee.com/user/signup" target="_blank">{l s='Sign Up' mod='wallee'}</a> <a class="btn btn-default" href="https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.6/docs/en/documentation.html" target="_blank">{l s='Documentation' mod='wallee'}</a></p>
<p><a class="btn btn-default" href="https://app-wallee.com/user/signup" target="_blank">{l s='Sign Up' mod='wallee'}</a> <a class="btn btn-default" href="https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.7/docs/en/documentation.html" target="_blank">{l s='Documentation' mod='wallee'}</a></p>
</div>
1 change: 1 addition & 0 deletions wallee-sdk/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ sudo: false
php:
- 8.0
- 8.1
- 8.2
before_install: "composer install"
script: "phpunit --bootstrap autoload.php test/"
2 changes: 1 addition & 1 deletion wallee-sdk/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 wallee-sdk/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.
5 changes: 3 additions & 2 deletions wallee-sdk/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wallee/sdk",
"version": "3.2.0",
"version": "4.2.0",
"description": "wallee SDK for PHP",
"keywords": [
"wallee",
Expand All @@ -14,7 +14,8 @@
"authors": [
{
"name": "wallee AG",
"homepage": "https://wallee.com"
"email": "[email protected]",
"homepage": "https://www.wallee.com"
}
],
"require": {
Expand Down
18 changes: 15 additions & 3 deletions wallee-sdk/lib/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @category Class
* @package Wallee\Sdk
* @author customweb GmbH
* @author wallee AG
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
*/
final class ApiClient {
Expand All @@ -48,7 +48,7 @@ final class ApiClient {
* @var array
*/
private $defaultHeaders = [
'x-meta-sdk-version' => "3.2.0",
'x-meta-sdk-version' => "4.2.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/3.2.0/php';
private $userAgent = 'PHP-Client/4.2.0/php';

/**
* The path to the certificate authority file.
Expand Down Expand Up @@ -1833,6 +1833,18 @@ public function getWebAppService() {
return $this->webAppService;
}

protected $webhookEncryptionService;

/**
* @return \Wallee\Sdk\Service\WebhookEncryptionService
*/
public function getWebhookEncryptionService() {
if(is_null($this->webhookEncryptionService)){
$this->webhookEncryptionService = new \Wallee\Sdk\Service\WebhookEncryptionService($this);
}
return $this->webhookEncryptionService;
}

protected $webhookListenerService;

/**
Expand Down
2 changes: 1 addition & 1 deletion wallee-sdk/lib/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @category Class
* @package Wallee\Sdk
* @author customweb GmbH
* @author wallee AG
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
*/
class ApiException extends Exception
Expand Down
2 changes: 1 addition & 1 deletion wallee-sdk/lib/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @category Class
* @package Wallee\Sdk
* @author customweb GmbH
* @author wallee AG
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
*/
class ApiResponse {
Expand Down
8 changes: 4 additions & 4 deletions wallee-sdk/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @category Class
* @package Wallee\Sdk
* @author customweb GmbH
* @author wallee AG
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
*/
class Configuration
Expand Down Expand Up @@ -80,7 +80,7 @@ class Configuration
*
* @var string
*/
protected $userAgent = 'Wallee\Sdk/3.2.0/php';
protected $userAgent = 'Wallee\Sdk/4.2.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: 3.2.0' . PHP_EOL;
$report .= ' SDK Package Version: 3.2.0' . PHP_EOL;
$report .= ' OpenAPI Spec Version: 4.2.0' . PHP_EOL;
$report .= ' SDK Package Version: 4.2.0' . PHP_EOL;
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;

return $report;
Expand Down
77 changes: 77 additions & 0 deletions wallee-sdk/lib/EncryptionUtil.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* wallee SDK
*
* This library allows to interact with the wallee payment service.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


namespace Wallee\Sdk;

use \Exception;

/**
* EncryptionUtil Class Doc Comment
*
* @category Class
* @package Wallee\Sdk
* @author wallee AG
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
*/
class EncryptionUtil
{
/**
* Verify content with signature
*
* @param string $contentToVerify Content to verify (required)
* @param string $contentSignature Content signature (required)
* @param string $encodedPublicKey Base64 encoded public key (required)
* @param string $signatureAlgorithm Signature algorithm (required)
* @throws RuntimeException
* @return bool
*/
public static function isContentValid($contentToVerify, $contentSignature, $encodedPublicKey, $signatureAlgorithm) {
switch ($signatureAlgorithm) {
case "SHA256withECDSA":
$publicKey = self::getPublicKey($encodedPublicKey);
$openSSLAlgorithm = OPENSSL_ALGO_SHA256;
break;
default:
throw new Exception("Unknown webhook signature encryption algorithm: " . $signatureAlgorithm);
}

$verification = openssl_verify($contentToVerify, base64_decode($contentSignature), $publicKey, $openSSLAlgorithm);

if (PHP_VERSION_ID < 80000) {
openssl_free_key($publicKey);
}

return $verification == 1;
}

private static function getPublicKey($encodedPublicKey) {
$pem = "-----BEGIN PUBLIC KEY-----\n" . chunk_split($encodedPublicKey, 64, "\n") . "-----END PUBLIC KEY-----";

// Create the public key resource
$publicKey = openssl_pkey_get_public($pem);

if (!$publicKey) {
throw new Exception("Failed to create public key from base64 string");
}

return $publicKey;
}

}
4 changes: 2 additions & 2 deletions wallee-sdk/lib/HeaderSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*
* @category Class
* @package Wallee\Sdk
* @author customweb GmbH
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
* @author wallee AG
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
*/
class HeaderSelector
{
Expand Down
2 changes: 1 addition & 1 deletion wallee-sdk/lib/Http/ConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @category Class
* @package Wallee\Sdk\Http
* @author customweb GmbH
* @author wallee AG
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
*/
final class ConnectionException extends Exception {
Expand Down
Loading

0 comments on commit 4eefab8

Please sign in to comment.