Skip to content

Commit

Permalink
Merge pull request #33 from shopware/next-40076/fix-empty-iap-message
Browse files Browse the repository at this point in the history
NEXT-40076 - fix empty IAP message
  • Loading branch information
mstegmeyer authored Dec 17, 2024
2 parents 7ece9cc + c27d157 commit 93cd344
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
6 changes: 1 addition & 5 deletions src/Context/ContextResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ public function assembleModule(RequestInterface $request, ShopInterface $shop):
throw new MalformedWebhookBodyException();
}

if (isset($params['in-app-purchases'])) {
if (empty($params['in-app-purchases'])) {
throw new MalformedWebhookBodyException();
}

if (!empty($params['in-app-purchases'])) {
/** @var non-empty-string $inAppPurchaseString */
$inAppPurchaseString = $params['in-app-purchases'];
$inAppPurchases = $this->inAppPurchaseProvider->decodePurchases($inAppPurchaseString, $shop);
Expand Down
12 changes: 0 additions & 12 deletions tests/Context/ContextResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,6 @@ public function testAssembleModule(): void
static::assertFalse($module->inAppPurchases->has('baz'));
}

public function testAssembleModuleWithEmptyInAppPurchasesThrows(): void
{
$contextResolver = new ContextResolver($this->createMock(InAppPurchaseProvider::class));

static::expectException(MalformedWebhookBodyException::class);

$contextResolver->assembleModule(
new Request('GET', 'http://localhost:6001/module/test?shop-id=vvRy7Nv3Bo8mAVda&shop-url=http://localhost:8000&timestamp=1683015472&sw-version=6.5.9999999.9999999-dev&sw-context-language=2fbb5fe2e29a4d70aa5854ce7ce3e20b&sw-user-language=en-GB&in-app-purchases=&shopware-shop-signature=650455d43eda4eeb4c9a12ee0eb15b46ce88776abaf9beb1ffac31be136e1d9b'),
$this->getShop()
);
}

#[DataProvider('assembleModuleInvalidRequestBodyProvider')]
public function testAssembleModuleInvalid(string $uri): void
{
Expand Down

0 comments on commit 93cd344

Please sign in to comment.