Reputation: 283
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
?
Upvotes: 0
Views: 113
Reputation: 13161
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();
Upvotes: 0