Skip to content

Commit d89f388

Browse files
authored
Merge pull request #12 from vienthuong/1.3.2
Release 1.3.1 - Shopware 6.5 compatibility
2 parents f1d80a4 + be90c21 commit d89f388

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to `shopware-php-sdk` will be documented in this file.
44

55
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
66

7+
### 1.3.2
8+
- Shopware 6.5 compatibility
9+
- `WebhookAuthenticator::authenticateGetRequest` now also consider `sw-context-language` and `sw-user-language`
10+
- Added properties `userLanguage` and `contextLanguage` into `IFrameRequest`
11+
712
### 1.3.1
813
- [Hydrate Bug fixed](https://github.com/vienthuong/shopware-php-sdk/issues/10)
914
- Update Latest DAL Classes

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "A PHP SDK for Shopware 6 Platform",
44
"type": "library",
55
"license": "MIT",
6-
"version": "1.3.1",
6+
"version": "1.3.2",
77
"authors": [
88
{
99
"name": "vin",

src/Data/Webhook/IFrameRequest/IFrameRequest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ class IFrameRequest extends Struct
1717

1818
protected ?string $shopwareShopSignature;
1919

20+
protected ?string $contextLanguage;
21+
22+
protected ?string $userLanguage;
23+
2024
public function __construct(array $parameters = [])
2125
{
2226
$this->shopId = $parameters[ShopRequest::SHOP_ID_REQUEST_PARAMETER];
2327
$this->shopUrl = $parameters[ShopRequest::SHOP_URL_REQUEST_PARAMETER];
28+
$this->contextLanguage = $parameters[ShopRequest::SHOP_CONTEXT_LANGUAGE] ?? null;
29+
$this->userLanguage = $parameters[ShopRequest::SHOP_USER_LANGUAGE] ?? null;
2430
$this->swVersion = $parameters[ShopRequest::SHOPWARE_VERSION_REQUEST_PARAMETER] ?? 'na';
2531
$this->timestamp = (int) $parameters[ShopRequest::TIME_STAMP_REQUEST_PARAMETER];
2632
$this->shopwareShopSignature = $parameters[ShopRequest::SHOP_SIGNATURE_REQUEST_PARAMETER] ?? null;
@@ -50,4 +56,14 @@ public function getShopwareShopSignature(): ?string
5056
{
5157
return $this->shopwareShopSignature;
5258
}
59+
60+
public function getContextLanguage(): ?string
61+
{
62+
return $this->contextLanguage;
63+
}
64+
65+
public function getUserLanguage(): ?string
66+
{
67+
return $this->userLanguage;
68+
}
5369
}

src/Data/Webhook/ShopRequest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ class ShopRequest
1313
public const SHOPWARE_VERSION_REQUEST_PARAMETER = 'sw-version';
1414

1515
public const SHOP_SIGNATURE_REQUEST_PARAMETER = 'shopware-shop-signature';
16+
17+
public const SHOP_CONTEXT_LANGUAGE = 'sw-context-language';
18+
19+
public const SHOP_USER_LANGUAGE = 'sw-user-language';
1620
}

src/Service/WebhookAuthenticator.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ public static function authenticateGetRequest(string $shopSecret): bool
5959
$queries['sw-version'],
6060
);
6161

62+
if (array_key_exists('sw-context-language', $queries) && array_key_exists('sw-context-language', $queries)) {
63+
$queryString = sprintf(
64+
'shop-id=%s&shop-url=%s&timestamp=%s&sw-version=%s&sw-context-language=%s&sw-user-language=%s',
65+
$shop->getShopId(),
66+
$shop->getShopUrl(),
67+
$queries['timestamp'],
68+
$queries['sw-version'],
69+
$queries['sw-context-language'],
70+
$queries['sw-user-language'],
71+
);
72+
}
73+
6274
$hmac = \hash_hmac('sha256', htmlspecialchars_decode($queryString), $shopSecret);
6375

6476
return hash_equals($hmac, $queries['shopware-shop-signature']);

0 commit comments

Comments
 (0)