The ContextResolver helps you map the Shopware requests to struct classes to work with them more easily. It also does some validation and checks if the request is valid.
$app = new AppConfiguration('Foo', 'test', 'http://localhost:6001/register/callback');
// for a repository to save stores implementing \Shopware\App\SDK\Shop\ShopRepositoryInterface, see FileShopRepository as an example
$repository = ...;
// Create a psr 7 request or convert it (HttpFoundation Symfony)
$psrRequest = ...;
$registrationService = new \Shopware\App\SDK\Registration\RegistrationService($app, $repository);
$shopResolver = new \Shopware\App\SDK\Shop\ShopResolver($repository);
$contextResolver = new \Shopware\App\SDK\Context\ContextResolver();
// Find the actual shop by the request
$shop = $shopResolver->resolveShop($psrRequest);
// Parse the request as a webhook
$webhook = $contextResolver->assembleWebhook($psrRequest, $shop);
$webhook->eventName; // the event name
$webhook->payload; // the event data
- Webhook - Webhooks or App lifecycle events
- ActionButton - Administration buttons
- Module - Iframe
- TaxProvider - Tax calculation
- Payment Pay - Payment pay action
- Payment Capture - Payment capture action
- Payment Validate - Payment validate action
- Payment Finalize - Payment finalize action
Next, we will look into the Signing of responses.