|
9 | 9 | use Shopware\App\SDK\Context\ActionButton\ActionButtonAction; |
10 | 10 | use Shopware\App\SDK\Context\Cart\Cart; |
11 | 11 | use Shopware\App\SDK\Context\Gateway\Checkout\CheckoutGatewayAction; |
| 12 | +use Shopware\App\SDK\Context\Gateway\Context\ContextGatewayAction; |
12 | 13 | use Shopware\App\SDK\Context\Gateway\InAppFeatures\FilterAction; |
13 | 14 | use Shopware\App\SDK\Context\InAppPurchase\InAppPurchaseProvider; |
14 | 15 | use Shopware\App\SDK\Context\Module\ModuleAction; |
@@ -288,6 +289,24 @@ public function assembleCheckoutGatewayRequest(RequestInterface $request, ShopIn |
288 | 289 | ); |
289 | 290 | } |
290 | 291 |
|
| 292 | + public function assembleContextGatewayRequest(RequestInterface $request, ShopInterface $shop): ContextGatewayAction |
| 293 | + { |
| 294 | + $body = \json_decode($request->getBody()->getContents(), true, flags: \JSON_THROW_ON_ERROR); |
| 295 | + $request->getBody()->rewind(); |
| 296 | + |
| 297 | + if (!\is_array($body) || !isset($body['source']) || !\is_array($body['source']) || !isset($body['data']) || !\is_array($body['data'])) { |
| 298 | + throw new MalformedWebhookBodyException(); |
| 299 | + } |
| 300 | + |
| 301 | + return new ContextGatewayAction( |
| 302 | + $shop, |
| 303 | + $this->parseSource($body['source'], $shop), |
| 304 | + new Cart($body['cart']), |
| 305 | + new SalesChannelContext($body['salesChannelContext']), |
| 306 | + $body['data'], |
| 307 | + ); |
| 308 | + } |
| 309 | + |
291 | 310 | public function assembleInAppPurchasesFilterRequest(RequestInterface $request, ShopInterface $shop): FilterAction |
292 | 311 | { |
293 | 312 | $body = \json_decode($request->getBody()->getContents(), true, flags: \JSON_THROW_ON_ERROR); |
|
0 commit comments