How Do I Retrieve The $queryString Variable Value During Shopware App Installation

98 Views Asked by At

I am trying to recalculate the signature sent from Shopware during the App Installation (Registration).

Following the code guide on the page

use Psr\Http\Message\RequestInterface;
​
/** @var RequestInterface $request */
$queryString = $request->getUri()->getQuery();
$signature = hash_hmac('sha256', $queryString, $appSecret);

How do I get the $queryString?

1

There are 1 best solutions below

2
On

Here's an example using symfony/http-foundation

<?php

require __DIR__ . '/vendor/autoload.php';

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;

$request = Request::createFromGlobals();
$query = $request->query->all();
$proof = \hash_hmac(
    'sha256',
    $query['shop-id'] . $query['shop-url'] . 'TestApp',
    'verysecret'
);

$response = new JsonResponse([
    'proof' => $proof,
    'secret' => 'verysecret',
    'confirmation_url' => 'http://localhost/confirm.php'
]);

$response->send();